示例#1
1
	ArgsChoiceControl(wxWindow* parent, vector<arg_val_t>& choices)
		: ArgsControl(parent), choices(choices)
	{
		choice_control = new wxComboBox(this, -1, "", wxDefaultPosition, wxSize(100, -1));
		choice_control->SetValidator(ComboBoxAwareIntegerValidator<unsigned char>());

		for (unsigned i = 0; i < choices.size(); i++)
		{
			choice_control->Append(
				S_FMT("%d: %s", choices[i].value, choices[i].name));
		}

		GetSizer()->Add(choice_control, wxSizerFlags().Expand());
	}
示例#2
0
	SLADECrashDialog(SLADEStackTrace& st) : wxDialog(wxTheApp->GetTopWindow(), -1, "SLADE3 Application Crash")
	{
		// Setup sizer
		wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
		SetSizer(sizer);

		// Add general crash method
		string message = "SLADE3 has crashed unexpectedly. To help fix the problem that caused this crash,\nplease copy+paste the information from the window below to a text file, and email\nit to <*****@*****.**> along with a description of what you were\ndoing at the time of the crash. Sorry for the inconvenience.";
		sizer->Add(new wxStaticText(this, -1, message), 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 4);

		// Setup stack trace string
		string trace = S_FMT("Version: %s\n", Global::version);
		if (current_action.IsEmpty())
			trace += "No current action\n";
		else
			trace += S_FMT("Current action: %s", current_action);
		trace += "\n";
		trace += st.getTraceString();

		// Add stack trace text area
		text_stack = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL);
		text_stack->SetValue(trace);
		text_stack->SetFont(wxFont(8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
		sizer->Add(text_stack, 1, wxEXPAND|wxALL, 4);

		// Dump stack trace to a file (just in case)
		wxFile file(appPath("slade3_crash.log", DIR_USER), wxFile::write);
		file.Write(trace);
		file.Close();

		// Add standard 'OK' button
		sizer->Add(CreateStdDialogButtonSizer(wxOK), 0, wxEXPAND|wxALL, 4);

		// Setup layout
		Layout();
		SetInitialSize(wxSize(500, 500));
	}
示例#3
0
// -----------------------------------------------------------------------------
// Loads [entry] into the EntryPanel.
// Returns false if the map was invalid, true otherwise
// -----------------------------------------------------------------------------
bool MapEntryPanel::loadEntry(ArchiveEntry* entry)
{
	// Clear current map data
	map_canvas_->clearMap();

	// Find map definition for entry
	vector<Archive::MapDesc> maps = entry->getParent()->detectMaps();
	Archive::MapDesc         thismap;
	bool                     found = false;
	for (unsigned a = 0; a < maps.size(); a++)
	{
		if (maps[a].head == entry)
		{
			thismap = maps[a];
			found   = true;
			break;
		}
	}

	// All errors = invalid map
	Global::error = "Invalid map";

	// There is no map entry for the map marker.
	// This may happen if a map marker lump is copy/pasted without the rest of the map lumps.
	if (!found)
	{
		entry->setType(EntryType::unknownType());
		EntryType::detectEntryType(entry);
		return false;
	}

	// Load map into preview canvas
	if (map_canvas_->openMap(thismap))
	{
		label_stats_->SetLabel(S_FMT(
			"Vertices: %d, Sides: %d, Lines: %d, Sectors: %d, Things: %d, Total Size: %dx%d",
			map_canvas_->nVertices(),
			map_canvas_->nSides(),
			map_canvas_->nLines(),
			map_canvas_->nSectors(),
			map_canvas_->nThings(),
			map_canvas_->getWidth(),
			map_canvas_->getHeight()));
		return true;
	}

	label_stats_->SetLabel("");
	return false;
}
示例#4
0
wxString MOPGAngleProperty::ValueToString(wxVariant &value, int argFlags) const {
	int angle = value.GetInteger();

	switch (angle) {
	case 0:		return "0: East"; break;
	case 45:	return "45: Northeast"; break;
	case 90:	return "90: North"; break;
	case 135:	return "135: Northwest"; break;
	case 180:	return "180: West"; break;
	case 225:	return "225: Southwest"; break;
	case 270:	return "270: South"; break;
	case 315:	return "315: Southeast"; break;
	default:	return S_FMT("%d", angle); break;
	}
}
示例#5
0
/* CTexture::asText
 * Returns a string representation of the texture, in ZDoom TEXTURES
 * format
 *******************************************************************/
string CTexture::asText()
{
	// Can't write non-extended texture as text
	if (!extended)
		return "";

	// Init text string
	string text;
	if (optional)
		text = S_FMT("%s Optional %s, %d, %d\n{\n", CHR(type), CHR(name), width, height);
	else
		text = S_FMT("%s %s, %d, %d\n{\n", CHR(type), CHR(name), width, height);

	// Write texture properties
	if (scale_x != 1.0)
		text += S_FMT("\tXScale %1.1f\n", scale_x);
	if (scale_y != 1.0)
		text += S_FMT("\tYScale %1.1f\n", scale_y);
	if (offset_x != 0 || offset_y != 0)
		text += S_FMT("\tOffset %d, %d\n", offset_x, offset_y);
	if (world_panning)
		text += "\tWorldPanning\n";
	if (no_decals)
		text += "\tNoDecals\n";
	if (null_texture)
		text += "\tNullTexture\n";

	// Write patches
	for (unsigned a = 0; a < patches.size(); a++)
		text += ((CTPatchEx*)patches[a])->asText();

	// Write ending
	text += "}\n\n";

	return text;
}
示例#6
0
/* MapEditorWindow::saveLayout
 * Saves the current window layout to a file
 *******************************************************************/
void MapEditorWindow::saveLayout()
{
	// Open layout file
	wxFile file(appPath("mapwindow.layout", DIR_USER), wxFile::write);

	// Write component layout
	wxAuiManager* m_mgr = wxAuiManager::GetManager(this);

	// Console pane
	file.Write("\"console\" ");
	string pinf = m_mgr->SavePaneInfo(m_mgr->GetPane("console"));
	file.Write(S_FMT("\"%s\"\n", pinf));

	// Item info pane
	file.Write("\"item_props\" ");
	pinf = m_mgr->SavePaneInfo(m_mgr->GetPane("item_props"));
	file.Write(S_FMT("\"%s\"\n", pinf));

	// Script editor pane
	file.Write("\"script_editor\" ");
	pinf = m_mgr->SavePaneInfo(m_mgr->GetPane("script_editor"));
	file.Write(S_FMT("\"%s\"\n", pinf));

	// Map checks pane
	file.Write("\"map_checks\" ");
	pinf = m_mgr->SavePaneInfo(m_mgr->GetPane("map_checks"));
	file.Write(S_FMT("\"%s\"\n", pinf));

	// Undo history pane
	file.Write("\"undo_history\" ");
	pinf = m_mgr->SavePaneInfo(m_mgr->GetPane("undo_history"));
	file.Write(S_FMT("\"%s\"\n", pinf));

	// Close file
	file.Close();
}
示例#7
0
// ----------------------------------------------------------------------------
// TextLanguage::getAutocompletionList
//
// Returns a string containing all words and functions that can be used
// directly in scintilla for an autocompletion list
// ----------------------------------------------------------------------------
string TextLanguage::autocompletionList(string start, bool include_custom)
{
	// Firstly, add all functions and word lists to a wxArrayString
	wxArrayString list;
	start = start.Lower();

	// Add word lists
	for (unsigned type = 0; type < 4; type++)
	{
		for (auto& word : word_lists_[type].list)
			if (word.Lower().StartsWith(start))
				list.Add(S_FMT("%s?%d", word, type + 1));

		if (!include_custom)
			continue;

		for (auto& word : word_lists_custom_[type].list)
			if (word.Lower().StartsWith(start))
				list.Add(S_FMT("%s?%d", word, type + 1));
	}

	// Add functions
	for (auto& func : functions_)
		if (func.name().Lower().StartsWith(start))
			list.Add(S_FMT("%s%s", func.name(), "?3"));

	// Sort the list
	list.Sort();

	// Now build a string of the list items separated by spaces
	string ret;
	for (unsigned a = 0; a < list.size(); a++)
		ret += list[a] + " ";

	return ret;
}
示例#8
0
/* AnimatedEntryPanel::onSwirlChanged
 * Called when the 'swirl' checkbox is toggled
 *******************************************************************/
void AnimatedEntryPanel::onSwirlChanged(wxCommandEvent& e)
{
	if (cbox_swirl->GetValue() != ae_current->getSpeed() > 65535)
	{
		ae_modified = true;
		setModified(true);

		if (cbox_swirl->GetValue())
			ae_current->setSpeed(65536);
		else
			ae_current->setSpeed(8);

		text_speed->ChangeValue(S_FMT("%d", ae_current->getSpeed()));
	}
}
示例#9
0
/* MapEntryPanel::createImage
 * Creates a PNG file of the map preview
 * as well as for image size
 *******************************************************************/
bool MapEntryPanel::createImage()
{
	if (entry == NULL)
		return false;

	ArchiveEntry temp;
	// Stupid OpenGL grumble grumble grumble
	if (GLEW_ARB_framebuffer_object)
		map_canvas->createImage(temp, map_image_width, map_image_height);
	else
		map_canvas->createImage(temp, min<int>(map_image_width, map_canvas->GetSize().x),
		                        min<int>(map_image_height, map_canvas->GetSize().y));
	string name = S_FMT("%s_%s", entry->getParent()->getFilename(false), entry->getName());
	wxFileName fn(name);

	// Create save file dialog
	wxFileDialog dialog_save(this, S_FMT("Save Map Preview \"%s\"", name),
	                         dir_last, fn.GetFullName(), "PNG (*.PNG)|*.png",
	                         wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition);

	// Run the dialog & check that the user didn't cancel
	if (dialog_save.ShowModal() == wxID_OK)
	{
		// If a filename was selected, export it
		bool ret = temp.exportFile(dialog_save.GetPath());

		// Save 'dir_last'
		dir_last = dialog_save.GetDirectory();

		// Open the saved image
		wxLaunchDefaultApplication(dialog_save.GetPath());

		return ret;
	}
	return true;
}
示例#10
0
/* GfxEntryPanel::sliderZoomChanged
 * Called when the zoom slider is changed
 *******************************************************************/
void GfxEntryPanel::onZoomChanged(wxCommandEvent& e)
{
	// Get zoom value
	int zoom_percent = slider_zoom->GetValue();

	// Lock to 10% increments
	int remainder = zoom_percent % 10;
	zoom_percent -= remainder;

	// Update zoom label
	label_current_zoom->SetLabel(S_FMT("%d%%", zoom_percent));

	// Zoom gfx canvas and update
	gfx_canvas->setScale((double)zoom_percent * 0.01);
	gfx_canvas->Refresh();
}
示例#11
0
/* ActionSpecial::reset
 * Resets all values to defaults
 *******************************************************************/
void ActionSpecial::reset()
{
	// Reset variables
	name = "Unknown";
	group = "";
	tagged = 0;

	// Reset args
	for (unsigned a = 0; a < 5; a++)
	{
		args[a].name = S_FMT("Arg%d", a+1);
		args[a].type = ARGT_NUMBER;
		args[a].custom_flags.clear();
		args[a].custom_values.clear();
	}
}
示例#12
0
/* TextureEditorPanel::onZoomChanged
 * Called when the zoom slider is changed
 *******************************************************************/
void TextureEditorPanel::onZoomChanged(wxCommandEvent& e)
{
	// Get zoom value
	int zoom_percent = slider_zoom->GetValue();

	// Lock to 10% increments
	int remainder = zoom_percent % 10;
	zoom_percent -= remainder;

	// Update zoom label
	label_current_zoom->SetLabel(S_FMT("%d%%", zoom_percent));

	// Zoom gfx canvas and update
	tex_canvas->setScale((double)zoom_percent * 0.01);
	tex_canvas->redraw(false);
}
示例#13
0
/* ArchiveManager::openBaseResource
 * Opens the base resource archive [index]
 *******************************************************************/
bool ArchiveManager::openBaseResource(int index)
{
	// Check we're opening a different archive
	if (base_resource_archive && base_resource == index)
		return true;

	// Close/delete current base resource archive
	if (base_resource_archive)
	{
		theResourceManager->removeArchive(base_resource_archive);
		delete base_resource_archive;
		base_resource_archive = NULL;
	}

	// Check index
	if (index < 0 || (unsigned)index >= base_resource_paths.size())
	{
		base_resource = -1;
		announce("base_resource_changed");
		return false;
	}

	// Create archive based on file type
	string filename = base_resource_paths[index];
	if (WadArchive::isWadArchive(filename))
		base_resource_archive = new WadArchive();
	else if (ZipArchive::isZipArchive(filename))
		base_resource_archive = new ZipArchive();
	else
		return false;

	// Attempt to open the file
	theSplashWindow->show(S_FMT("Opening %s...", filename), true);
	if (base_resource_archive->open(filename))
	{
		base_resource = index;
		theSplashWindow->hide();
		theResourceManager->addArchive(base_resource_archive);
		announce("base_resource_changed");
		return true;
	}
	delete base_resource_archive;
	base_resource_archive = NULL;
	theSplashWindow->hide();
	announce("base_resource_changed");
	return false;
}
示例#14
0
void MOPGThingTypeProperty::openObjects(vector<MapObject*>& objects) {
	// Reset arg property names
	for (unsigned a = 0; a < 5; a++) {
		if (args[a]) {
			args[a]->SetLabel(S_FMT("Arg%d", a+1));
			args[a]->SetHelpString("");
		}
	}

	// Set unspecified if no objects given
	if (objects.size() == 0) {
		SetValueToUnspecified();
		return;
	}

	// Get property of first object
	int first = objects[0]->intProperty(GetName());

	// Check whether all objects share the same value
	for (unsigned a = 1; a < objects.size(); a++) {
		if (objects[a]->intProperty(GetName()) != first) {
			// Different value found, set unspecified
			SetValueToUnspecified();
			return;
		}
	}

	// Set to common value
	noupdate = true;
	if (!parent->showAll() && udmf_prop && !udmf_prop->showAlways() && udmf_prop->getDefaultValue().getIntValue() == first)
		Hide(true);
	else
		Hide(false);
	SetValue(first);
	noupdate = false;

	// Set arg property names
	ThingType* tt = theGameConfiguration->thingType(first);
	for (unsigned a = 0; a < 5; a++) {
		if (!args[a])
			continue;

		args[a]->SetLabel(tt->getArg(a).name);
		args[a]->SetHelpString(tt->getArg(a).desc);
	}
}
示例#15
0
/* ArchiveEntry::exportFile
 * Exports entry data to a file.
 * Returns false if file cannot be written, true otherwise
 *******************************************************************/
bool ArchiveEntry::exportFile(string filename)
{
	// Attempt to open file
	wxFile file(filename, wxFile::write);

	// Check it opened ok
	if (!file.IsOpened())
	{
		Global::error = S_FMT("Unable to open file %s for writing", filename);
		return false;
	}

	// Write entry data to the file
	file.Write(getData(), this->getSize());

	return true;
}
示例#16
0
/* Executables::writeExecutables
 * Writes all executable definitions as text
 *******************************************************************/
string Executables::writeExecutables()
{
	string ret = "executables\n{\n";

	// Write game exes
	for (auto& exe : game_exes)
	{
		// ID
		ret += S_FMT("\tgame_exe %s\n\t{\n", exe.id);

		// Name
		ret += S_FMT("\t\tname = \"%s\";\n", exe.name);

		// Exe name
		ret += S_FMT("\t\texe_name = \"%s\";\n\n", exe.exe_name);

		// Configs
		for (auto& config : exe.configs)
			ret += S_FMT(
				"\t\tconfig \"%s\" = \"%s\";\n",
				config.key,
				StringUtils::escapedString(config.value)
			);

		ret += "\t}\n\n";
	}

	// Write external exes
	for (auto& exe : external_exes)
	{
		// Name
		ret += S_FMT("\texternal_exe \"%s\"\n\t{\n", exe.name);

		// Entry Category
		ret += S_FMT("\t\tcategory = \"%s\";\n", exe.category);

		// Path
		string path = exe.path;
		path.Replace("\\", "/");
		ret += S_FMT("\t\tpath = \"%s\";\n", path);

		ret += "\t}\n\n";
	}

	ret += "}\n";

	return ret;
}
示例#17
0
// -----------------------------------------------------------------------------
// Opens the base resource archive [index]
// -----------------------------------------------------------------------------
bool ArchiveManager::openBaseResource(int index)
{
	// Check we're opening a different archive
	if (base_resource_archive_ && base_resource == index)
		return true;

	// Close/delete current base resource archive
	if (base_resource_archive_)
	{
		theResourceManager->removeArchive(base_resource_archive_.get());
		base_resource_archive_ = nullptr;
	}

	// Check index
	if (index < 0 || (unsigned)index >= base_resource_paths_.size())
	{
		base_resource = -1;
		announce("base_resource_changed");
		return false;
	}

	// Create archive based on file type
	string filename = base_resource_paths_[index];
	if (WadArchive::isWadArchive(filename))
		base_resource_archive_ = std::make_unique<WadArchive>();
	else if (ZipArchive::isZipArchive(filename))
		base_resource_archive_ = std::make_unique<ZipArchive>();
	else
		return false;

	// Attempt to open the file
	UI::showSplash(S_FMT("Opening %s...", filename), true);
	if (base_resource_archive_->open(filename))
	{
		base_resource = index;
		UI::hideSplash();
		theResourceManager->addArchive(base_resource_archive_.get());
		announce("base_resource_changed");
		return true;
	}
	base_resource_archive_ = nullptr;
	UI::hideSplash();
	announce("base_resource_changed");
	return false;
}
示例#18
0
/* TextStylePrefsPanel::onBtnSaveStyleSet
 * Called when the 'Save' style set button is clicked
 *******************************************************************/
void TextStylePrefsPanel::onBtnSaveStyleSet(wxCommandEvent& e)
{
	// Get name for set
	string name = wxGetTextFromUser("Enter Style Set name:", "Save Style Set");
	if (name.IsEmpty())
		return;

	// Create temp styleset
	StyleSet ss_temp(name);
	ss_temp.copySet(&ss_current);

	// Remove spaces from name (for filename)
	name.Replace(" ", "_");

	// Write set to file
	string filename = appPath(S_FMT("text_styles/%s.sss", name), DIR_USER);
	ss_temp.writeFile(filename);
}
示例#19
0
/* KeyBind::mbName
 * Returns a string representation of mouse [button]
 *******************************************************************/
string KeyBind::mbName(int button)
{
    switch (button)
    {
    case wxMOUSE_BTN_LEFT:
        return "mouse1";
    case wxMOUSE_BTN_RIGHT:
        return "mouse2";
    case wxMOUSE_BTN_MIDDLE:
        return "mouse3";
    case wxMOUSE_BTN_AUX1:
        return "mouse4";
    case wxMOUSE_BTN_AUX2:
        return "mouse5";
    default:
        return S_FMT("mouse%d", button);
    };
}
示例#20
0
/* AudioEntryPanel::onBtnPrev
 * Called when the previous track button is pressed
 *******************************************************************/
void AudioEntryPanel::onBtnPrev(wxCommandEvent& e)
{
	if (subsong > 0)
		subsong--;
	else subsong = num_tracks - 1;

	if (entry->getType()->getFormat() == "xmi")
	{
		MemChunk& mcdata = entry->getMCData();
		MemChunk convdata;
		if (Conversions::zmusToMidi(mcdata, convdata, subsong))
			openMidi(convdata, prevfile);
	}
	//else if (entry->getType()->getFormat().StartsWith("gme"))
	//	theGMEPlayer->play(subsong);
	txt_track->SetLabel(S_FMT("%d/%d", subsong+1, num_tracks));
	updateInfo();
}
示例#21
0
/* AudioEntryPanel::onBtnNext
 * Called when the next track button is pressed
 *******************************************************************/
void AudioEntryPanel::onBtnNext(wxCommandEvent& e)
{
	int newsong = (subsong + 1) % num_tracks;
	if (entry->getType()->getFormat() == "xmi")
	{
		MemChunk& mcdata = entry->getMCData();
		MemChunk convdata;
		if (Conversions::zmusToMidi(mcdata, convdata, newsong) && openMidi(convdata, prevfile))
			subsong = newsong;
	}
	/*else if (entry->getType()->getFormat().StartsWith("gme"))
	{
		if (theGMEPlayer->play(newsong))
			subsong = newsong;
	}*/
	txt_track->SetLabel(S_FMT("%d/%d", subsong+1, num_tracks));
	updateInfo();
}
示例#22
0
/* NodesPrefsPanel::populateOptions
 * Populates the options CheckListBox with options for the currently
 * selected node builder
 *******************************************************************/
void NodesPrefsPanel::populateOptions(string options)
{
	// Get current builder
	NodeBuilders::builder_t& builder = NodeBuilders::getBuilder(choice_nodebuilder->GetSelection());

	// Set builder path
	text_path->SetValue(builder.path);

	// Clear current options
	clb_options->Clear();

	// Add builder options
	for (unsigned a = 0; a < builder.option_desc.size(); a++)
	{
		clb_options->Append(builder.option_desc[a]);
		if (!options.IsEmpty() && options.Contains(S_FMT(" %s ", builder.options[a])))
			clb_options->Check(a);
	}
}
示例#23
0
	void setArgValue(long val)
	{
		if (val < 0)
		{
			choice_control->ChangeValue("");
			return;
		}

		// Look for a name for this value
		for (unsigned i = 0; i < choices.size(); i++)
		{
			if (val == choices[i].value)
			{
				choice_control->SetSelection(i);
				return;
			}
		}
		choice_control->ChangeValue(S_FMT("%ld", val));
	}
示例#24
0
/* TextureEditorPanel::updateTextureScaleLabel
 * Updates the 'Scaled Size' label according to the current texture's
 * dimensions and scale
 *******************************************************************/
void TextureEditorPanel::updateTextureScaleLabel()
{
	// Check texture is open
	if (!tex_current)
		return;

	// Determine scaled X value
	uint32_t scaled_x = tex_current->getWidth();
	if (tex_current->getScaleX() != 0)
		scaled_x /= tex_current->getScaleX();

	// Determine scaled Y value
	uint32_t scaled_y = tex_current->getHeight();
	if (tex_current->getScaleY() != 0)
		scaled_y /= tex_current->getScaleY();

	// Update the label
	label_scaled_size->SetLabel(S_FMT("Scaled Size: %dx%d", scaled_x, scaled_y));
}
示例#25
0
void LineTextureOverlay::browseTexture(tex_inf_t& tex, string position) {
	// Get initial texture
	string texture;
	if (tex.textures.size() > 0)
		texture = tex.textures[0];
	else
		texture = "-";

	// Open texture browser
	MapTextureBrowser browser(theMapEditor, 0, texture);
	browser.SetTitle(S_FMT("Browse %s Texture", CHR(position)));
	if (browser.ShowModal() == wxID_OK) {
		// Set texture
		tex.textures.clear();
		tex.textures.push_back(browser.getSelectedItem()->getName());
		tex.changed = true;
		close(false);
	}
}
示例#26
0
/* PaletteEntryPanel::addCustomPalette
 * Adds the current palette to the custom user palettes folder, so
 * it can be selected via the palette selector
 *******************************************************************/
bool PaletteEntryPanel::addCustomPalette()
{
	// Get name to export as
	string name = wxGetTextFromUser("Enter name for Palette:", "Add to Palettes");
	if (name.IsEmpty())
		return false;

	// Write current palette to the user palettes directory
	string path = appPath(S_FMT("palettes/%s.pal", name), DIR_USER);
	palettes[cur_palette]->saveFile(path);

	// Add to palette manager and main palette chooser
	Palette8bit* pal = new Palette8bit();
	pal->copyPalette(palettes[cur_palette]);
	thePaletteManager->addPalette(pal, name);
	thePaletteChooser->addPalette(name);

	return true;
}
示例#27
0
void BrowserCanvas::onKeyChar(wxKeyEvent& e) {
	// Check the key pressed is actually a character (a-z, 0-9 etc)
	bool isRealChar = false;
	if (e.GetKeyCode() >= 'a' && e.GetKeyCode() <= 'z')			// Lowercase
		isRealChar = true;
	else if (e.GetKeyCode() >= 'A' && e.GetKeyCode() <= 'Z')	// Uppercase
		isRealChar = true;
	else if (e.GetKeyCode() >= '0' && e.GetKeyCode() <= '9')	// Number
		isRealChar = true;
	else {
		for (int a = 0; a < n_bc_chars; a++) {
			if (e.GetKeyCode() == bc_chars[a]) {
				isRealChar = true;
				break;
			}
		}
	}

	if (isRealChar) {
		// Get currently selected item (or first if nothing is focused)
		int selected = itemIndex(item_selected);
		if (selected < 0) selected = 0;

		// Build search string
		search += e.GetKeyCode();
		search.MakeUpper();

		// Search for match from the current focus, and if failed
		// start a new search from after the current focus.
		if (!searchItemFrom(selected)) {
			search = S_FMT("%c", e.GetKeyCode());
			search.MakeUpper();
			searchItemFrom(selected+1);
		}

		// Refresh canvas
		Refresh();
	}
	else {
		search = "";
		e.Skip();
	}
}
示例#28
0
/* MainApp::initDirectories
 * Checks for and creates necessary application directories. Returns
 * true if all directories existed and were created successfully if
 * needed, false otherwise
 *******************************************************************/
bool MainApp::initDirectories()
{
	// Setup separator character
#ifdef WIN32
	string sep = "\\";
#else
	string sep = "/";
#endif

	// Setup app dir
	dir_app = wxFileName(wxStandardPaths::Get().GetExecutablePath()).GetPath();

	// Check for portable install
	if (wxFileExists(appPath("portable", DIR_APP)))
	{
		// Setup portable user/data dirs
		dir_data = dir_app;
		dir_user = dir_app + sep + "config";
	}
	else
	{
		// Setup standard user/data dirs
		dir_user = wxStandardPaths::Get().GetUserDataDir();
		dir_data = wxStandardPaths::Get().GetDataDir();
	}

	// Create user dir if necessary
	if (!wxDirExists(dir_user))
	{
		if (!wxMkdir(dir_user))
		{
			wxMessageBox(S_FMT("Unable to create user directory \"%s\"", dir_user), "Error", wxICON_ERROR);
			return false;
		}
	}

	// Check data dir
	if (!wxDirExists(dir_data))
		dir_data = dir_app;	// Use app dir if data dir doesn't exist

	return true;
}
示例#29
0
	void syncControls(int value)
	{
		ArgsTextControl::setArgValue(value);

		if (value < 0)
		{
			slider_control->SetValue(0);
			speed_label->SetLabel("");
		}
		else
		{
			slider_control->SetValue(value);
			speed_label->SetLabel(S_FMT(
				"%s (%.1f units per tic, %.1f units per sec)",
				arg_t::speedLabel(value), value / 8.0,
				// A tic is 28ms, slightly less than 1/35 of a second
				value / 8.0 * 1000.0 / 28.0
			));
		}
	}
示例#30
0
/* PaletteEntryPanel::showPalette
 * Shows the palette at [index]. Returns false if [index] is out of
 * bounds, true otherwise
 *******************************************************************/
bool PaletteEntryPanel::showPalette(uint32_t index)
{
	// Check index range
	if (index >= palettes.size())
		return false;

	// Copy palette at index into canvas
	pal_canvas->getPalette().copyPalette(palettes[index]);

	// Set current palette text
	text_curpal->SetLabel(S_FMT("%u/%lu", index+1, palettes.size()));

	// Refresh
	Layout();
	pal_canvas->Refresh();
	// The color values of the selected index have probably changed.
	updateStatus();

	return true;
}