Exemple #1
0
void MlSldaState::InitializeAssignments(bool random_init) {
  InitializeResponse();
  InitializeLength();

  LdawnState::InitializeAssignments(random_init);

  if (FLAGS_num_seed_docs > 0) {
    const gsl_vector* y = static_cast<lib_corpora::ReviewCorpus*>
      (corpus_.get())->train_ratings();
    boost::shared_ptr<gsl_permutation> sorted(gsl_permutation_alloc(y->size),
                                              gsl_permutation_free);
    boost::shared_ptr<gsl_permutation> rank(gsl_permutation_alloc(y->size),
                                            gsl_permutation_free);

    std::vector< std::vector<int> > num_seeds_used;
    num_seeds_used.resize(corpus_->num_languages());
    for (int ii = 0; ii < corpus_->num_languages(); ++ii) {
      num_seeds_used[ii].resize(num_topics_);
    }

    gsl_sort_vector_index(sorted.get(), y);
    gsl_permutation_inverse(rank.get(), sorted.get());

    // We add one for padding so we don't try to set a document to be equal to
    // the number of topics.
    double num_train = corpus_->num_train() + 1.0;
    int train_seen = 0;
    int num_docs = corpus_->num_docs();
    for (int dd = 0; dd < num_docs; ++dd) {
      MlSeqDoc* doc = corpus_->seq_doc(dd);
      int lang = doc->language();
      if (!corpus_->doc(dd)->is_test()) {
        // We don't assign to topic zero, so it can be stopwordy
        int val = (int) floor((num_topics_ - 1) *
                              rank->data[train_seen] / num_train) + 1;

        // Stop once we've used our limit of seed docs (too many leads to an
        // overfit initial state)
        if (num_seeds_used[lang][val] < FLAGS_num_seed_docs) {
          cout << "Initializing doc " << lang << " " << dd << " to " << val <<
            " score=" << truth_[dd] << endl;
          for (int jj = 0; jj < (int)topic_assignments_[dd].size(); ++jj) {
            int term = (*doc)[jj];
            const topicmod_projects_ldawn::WordPaths word =
              wordnet_->word(lang, term);
            int num_paths = word.size();
            if (num_paths > 0) {
              ChangePath(dd, jj, val, rand() % num_paths);
            } else {
              if (use_aux_topics())
                ChangeTopic(dd, jj, val);
            }
          }
          ++num_seeds_used[lang][val];
        }
        ++train_seen;
      }
    }
  }
}
// Cactive_pluginCtrl message handlers
BSTR Cactive_pluginCtrl::Plugin_Interface(LONG l, BSTR p)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	// TODO: Add your dispatch handler code here
	int cmd	= l;
	BSTR pRet = NULL;
	if (m_bCbReturn > 0 || (GetTickCount() - m_lastInvokeTime < 2000 && (cmd == 21/* || cmd == 11*/)) )
	{
		pRet = SetRetValue("{\"rst\":5}");
		return pRet;
	}
	m_bCbReturn = 1;
	if (cmd == 21/* || cmd == 11*/)
		m_lastInvokeTime = GetTickCount();

	char *js_parm	= (char *)p;
	switch(cmd)
	{
	case 1:		//设置工作模式和布局
		pRet = SetWorkModel(js_parm);
		break;
	case 2:		//改变布局
		pRet = ChangeLayout(js_parm);
		break;
	case 5:		//改变存储路径
		pRet = ChangePath(js_parm);
		break;
	case 21:	//打开历史流
		pRet = Play(js_parm);
		break;
	case 23:	//历史流跳转
		pRet = VodPlayJump(js_parm);
		break;
	case 11:	//播放实时视频
		pRet = Play(js_parm);
		break;
	case 3:		//得到当前焦点播放窗口参数
		pRet = GetWndParm(FOCUS_WINDOW);
		break;
	case 4:		//得到所有窗口播放参数列表
		pRet = GetWndParm(ALL_WINDOW);
		break;
	case 12:	//关闭所有播放
		pRet = StopAllPlay();
		break;
	case 22:	//关闭所有历史流
		pRet = StopAllPlay();
		break;
	case 30:	//播放器sleep
		//pRet = SleepPlayer((bool)NPVARIANT_TO_BOOLEAN(args[1]));
		break;
	default:
		break;
	}
	m_bCbReturn = 0;
	return pRet;
}
Exemple #3
0
CServerPath::CServerPath(const CServerPath &path, wxString subdir)
	: m_type(path.m_type)
	, m_data(path.m_data)
{
	if (subdir.empty())
		return;

	if (!ChangePath(subdir))
		clear();
}
bool CServerPath::SetPath(std::wstring &newPath, bool isFile)
{
	std::wstring path = newPath;
	std::wstring file;

	if (path.empty()) {
		return false;
	}

	if (m_type == DEFAULT) {
		size_t pos1 = path.find(L":[");
		if (pos1 != std::wstring::npos) {
			size_t pos2 = path.rfind(']');
			if (pos2 != std::string::npos && pos2 == (path.size() - 1) && !isFile) {
				m_type = VMS;
			}
			else if (isFile && pos2 > pos1) {
				m_type = VMS;
			}
		}
		else if (path.size() >= 3 &&
			((path[0] >= 'A' && path[0] <= 'Z') || (path[0] >= 'a' && path[0] <= 'z')) &&
			path[1] == ':' && (path[2] == '\\' || path[2] == '/'))
		{
			m_type = DOS;
		}
		else if (path[0] == FTP_MVS_DOUBLE_QUOTE && path.back() == FTP_MVS_DOUBLE_QUOTE) {
			m_type = MVS;
		}
		else if (path[0] == ':' && (pos1 = path.find(':'), 2) != std::wstring::npos) {
			size_t slash = path.find('/');
			if (slash == std::wstring::npos || slash > pos1) {
				m_type = VXWORKS;
			}
		}
		else if (path[0] == '\\') {
			m_type = DOS_VIRTUAL;
		}

		if (m_type == DEFAULT) {
			m_type = UNIX;
		}
	}

	m_data.clear();

	if (!ChangePath(path, isFile)) {
		return false;
	}

	if (isFile) {
		newPath = path;
	}
	return true;
}
CServerPath::CServerPath(CServerPath const& path, std::wstring subdir)
	: m_type(path.m_type)
	, m_data(path.m_data)
{
	if (subdir.empty()) {
		return;
	}

	if (!ChangePath(subdir)) {
		clear();
	}
}
Exemple #6
0
CServerPath::CServerPath(const CServerPath &path, wxString subdir)
	: m_data(path.m_data)
{
	m_type = path.m_type;
	m_bEmpty = path.m_bEmpty;

	if (subdir == _T(""))
		return;

	if (!ChangePath(subdir))
		Clear();
}
/** Compute the new contents of the voxel where the path should be added from the #_world. */
void PathBuildManager::ComputeWorldAdditions()
{
	assert(this->state == PBS_WAIT_BUY); // It needs selected_arrow and selected_slope.
	assert(this->selected_slope != TSL_INVALID);

	if (((1 << this->selected_slope) & this->allowed_slopes) == 0) return;

	XYZPoint16 arrow_pos = this->ComputeArrowCursorPosition();

	const Voxel *v = _world.GetVoxel(arrow_pos);
	if (v != nullptr && HasValidPath(v)) {
		ChangePath(arrow_pos, this->path_type, false);
		return;
	}

	TileEdge edge = (TileEdge)((this->selected_arrow + 2) % 4);
	switch (this->selected_slope) {
		case TSL_DOWN:
			v = _world.GetVoxel(arrow_pos + XYZPoint16(0, 0, -1));

			if (v != nullptr && HasValidPath(v)) {
				arrow_pos.z--;
				ChangePath(arrow_pos, this->path_type, false);
			} else {
				BuildDownwardPath(arrow_pos, edge, this->path_type, false);
			}
			break;

		case TSL_FLAT:
			BuildFlatPath(arrow_pos, this->path_type, false);
			break;

		case TSL_UP:
			BuildUpwardPath(arrow_pos, edge, this->path_type, false);
			break;

		default:
			NOT_REACHED();
	}
}
Exemple #8
0
bool CServerPath::SetPath(wxString &newPath, bool isFile)
{
	wxString path = newPath;
	wxString file;

	path.Trim(true);
	path.Trim(false);

	if (path == _T(""))
		return false;

	if (m_type == DEFAULT)
	{
		int pos1 = path.Find(_T(":["));
		if (pos1 != -1)
		{
			int pos2 = path.Find(']', true);
			if (pos2 != -1 && static_cast<size_t>(pos2) == (path.Length() - 1) && !isFile)
				m_type = VMS;
			else if (isFile && pos2 > pos1)
				m_type = VMS;
		}
		else if (path.Length() >= 3 &&
			((path.c_str()[0] >= 'A' && path.c_str()[0] <= 'Z') || (path.c_str()[0] >= 'a' && path.c_str()[0] <= 'z')) &&
			path.c_str()[1] == ':' && (path.c_str()[2] == '\\' || path.c_str()[2] == '/'))
				m_type = DOS;
		else if (path.c_str()[0] == FTP_MVS_DOUBLE_QUOTE && path.Last() == FTP_MVS_DOUBLE_QUOTE)
			m_type = MVS;
		else if (path[0] == ':' && (pos1 = path.Mid(1).Find(':')) > 0)
		{
			int slash = path.Find('/');
			if (slash == -1 || slash > pos1)
				m_type = VXWORKS;
		}
		else if (path[0] == '\\')
			m_type = DOS_VIRTUAL;

		if (m_type == DEFAULT)
			m_type = UNIX;
	}

	m_data.clear();
	m_bEmpty = true;

	if (!ChangePath(path, isFile))
		return false;

	if (isFile)
		newPath = path;
	return true;
}
/**
 * User clicked somewhere. Check whether it is a good tile or path, and if so, move the building process forward.
 * @param click_pos Coordinate of the voxel.
 */
void PathBuildManager::TileClicked(const XYZPoint16 &click_pos)
{
	if (this->state == PBS_IDLE || this->state > PBS_WAIT_BUY) return;

	if (this->state == PBS_SINGLE) {
		this->pos = click_pos;
		const Voxel *v = _world.GetCreateVoxel(this->pos, false);

		if (v != nullptr && HasValidPath(v)) {
			ChangePath(this->pos, this->path_type, false);
		} else {
			TileSlope ts = ExpandTileSlope(v->GetGroundSlope());

			if (ts == SL_FLAT) {
				BuildFlatPath(this->pos, this->path_type, false);
			} else {
				TileEdge edge = INVALID_EDGE;

				switch (ts) {
					case TSB_NORTHEAST:
						edge = EDGE_SW;
						break;
					case TSB_NORTHWEST:
						edge = EDGE_SE;
						break;
					case TSB_SOUTHEAST:
						edge = EDGE_NW;
						break;
					case TSB_SOUTHWEST:
						edge = EDGE_NE;
						break;
					default:
						return;
				}

				BuildUpwardPath(this->pos, edge, this->path_type, false);
			}
		}
		_additions.Commit();
	} else {
		uint8 dirs = GetPathAttachPoints(click_pos);
		if (dirs == 0) return;

		this->pos = click_pos;
		this->allowed_arrows = dirs;
		this->SetState(PBS_WAIT_ARROW);
	}
}
Exemple #10
0
void FileConfigTestCase::Path()
{
    wxStringInputStream sis(testconfig);
    wxFileConfig fc(sis);

    CPPUNIT_ASSERT( ChangePath(fc, wxT("")) == wxT("") );
    CPPUNIT_ASSERT( ChangePath(fc, wxT("/")) == wxT("") );
    CPPUNIT_ASSERT( ChangePath(fc, wxT("root")) == wxT("/root") );
    CPPUNIT_ASSERT( ChangePath(fc, wxT("/root")) == wxT("/root") );
    CPPUNIT_ASSERT( ChangePath(fc, wxT("/root/group1/subgroup")) == wxT("/root/group1/subgroup") );
    CPPUNIT_ASSERT( ChangePath(fc, wxT("/root/group2")) == wxT("/root/group2") );
}
Exemple #11
0
Prefs_Fonts::Prefs_Fonts(QWidget* parent, ScribusDoc* doc)
	: Prefs_Pane(parent),
	m_doc(doc)
{
	setupUi(this);

	RList = PrefsManager::instance()->appPrefs.fontPrefs.GFontSub;
	UsedFonts.clear();
	CurrentPath = "";
	m_askBeforeSubstitute = true;

	setMinimumSize(fontMetrics().width( tr( "Available Fonts" )+ tr( "Font Substitutions" )+ tr( "Additional Paths" ))+180, 200);

	fontListTableView->setModel(new FontListModel(fontListTableView, m_doc));

	fontSubstitutionsTableWidget->setRowCount(RList.count());
	fontSubstitutionsTableWidget->setColumnCount(2);
	fontSubstitutionsTableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem( tr("Font Name")));
	fontSubstitutionsTableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem( tr("Replacement")));
	fontSubstitutionsTableWidget->setSortingEnabled(false);
	fontSubstitutionsTableWidget->setSelectionBehavior( QAbstractItemView::SelectRows );
	QHeaderView *header = fontSubstitutionsTableWidget->horizontalHeader();
	header->setSectionsMovable(false);
	header->setSectionsClickable(false);
	header->setSectionResizeMode(QHeaderView::Stretch);
	fontSubstitutionsTableWidget->verticalHeader()->hide();
	fontSubstitutionsTableWidget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));


	// If we're being called for global application preferences, not document
	// preferences, we let the user customize font search paths. Because things
	// go rather badly if paths are changed/removed while a doc is open, the
	// control is also not displayed if there is a document open.
	if (m_doc==0 && !ScCore->primaryMainWindow()->HaveDoc)
	{
		whyBlankLabel->resize(0,0);
		whyBlankLabel->hide();
		readPaths();
		changeButton->setEnabled(false);
		removeButton->setEnabled(false);
		connect(pathListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(SelectPath(QListWidgetItem*)));
		connect(addButton, SIGNAL(clicked()), this, SLOT(AddPath()));
		connect(changeButton, SIGNAL(clicked()), this, SLOT(ChangePath()));
		connect(removeButton, SIGNAL(clicked()), this, SLOT(DelPath()));
	}
Exemple #12
0
bool CServerPath::ChangePath(wxString subdir)
{
	wxString subdir2 = subdir;
	return ChangePath(subdir2, false);
}
////////////////////////////////////////////////////////////////////////
// When the user pressed the Enter or double-clicked...
void PanelView::Execute(CustomListItem *item)
////////////////////////////////////////////////////////////////////////
{
	BString execute;

	switch (item->m_Type)
	{
		case FT_DISKITEM:
			SetPanelMode(PM_NORMAL);
			ChangePath(item->m_DiskPath.String());			
			break;
		case FT_DISKBACK:
			SetPanelMode(PM_NORMAL);
			ChangePath(m_Path.String());
			break;
		case FT_PARENT:
			GotoParent();
			break;
		case FT_DIRECTORY:
			EnterDirectory(item->m_FileName.String());
			break;
		case FT_SYMLINKDIR:
		case FT_SYMLINKFILE:	// TODO: ha mar ugyis tudjuk elore....
			{
				BEntry symlinkentry;
				entry_ref ref;

				execute.SetTo(m_Path.String());
				execute+="/";
				execute+=item->m_FileName;

				BEntry entry(execute.String());
				entry.GetRef(&ref);
				symlinkentry.SetTo(&ref, true);
				if (symlinkentry.IsDirectory())		// Is it a directory?
				{
					BPath symlinkpath;
					symlinkentry.GetPath(&symlinkpath);
					ChangePath(symlinkpath.Path());
				}
				else	// No, it is a standard file....
				{
					// Launch the selected file or document...
					if (entry.GetRef(&ref) == B_OK)
						be_roster->Launch(&ref);
				}
			}
			break;
		case FT_FILE:
			{
				// Launch the selected file or document...
				entry_ref ref;

				execute.SetTo(m_Path.String());
				execute+="/";
				execute+=item->m_FileName;

				BEntry entry(execute.String());
				if (entry.GetRef(&ref) == B_OK)
					be_roster->Launch(&ref);
			}
			break;
	}
}
// ChangeDirectory():
//  Synonym for ChangePath()
char * DirStrings::ChangeDirectory( char *output, const char *new_path ) {
  return ChangePath( output, new_path );
}
bool CServerPath::ChangePath(std::wstring const& subdir)
{
	std::wstring subdir2 = subdir;
	return ChangePath(subdir2, false);
}
Exemple #16
0
FontPrefs::FontPrefs( QWidget* parent, bool Hdoc, QString PPath, ScribusDoc* doc ) : QTabWidget( parent )
{
	RList = PrefsManager::instance()->appPrefs.GFontSub;
	HomeP = PPath;
	DocAvail = Hdoc;
	UsedFonts.clear();
	CurrentPath = "";
	docc = doc;
	setMinimumSize(fontMetrics().width( tr( "Available Fonts" )+ tr( "Font Substitutions" )+ tr( "Additional Paths" ))+180, 200);
	tab1 = new QWidget( this );
	tab1Layout = new QVBoxLayout( tab1 );
	tab1Layout->setMargin(10);
	tab1Layout->setSpacing(5);

	fontList = new FontListView(tab1);
	fontList->setModel(new FontListModel(fontList));

	tab1Layout->addWidget( fontList );
	addTab( tab1, tr( "&Available Fonts" ) );

	tab = new QWidget( this );
	tabLayout = new QVBoxLayout( tab );
	tabLayout->setMargin(10);
	tabLayout->setSpacing(5);

	Table3 = new QTableWidget(0, 2, tab );
	Table3->setHorizontalHeaderItem(0, new QTableWidgetItem( tr("Font Name")));
	Table3->setHorizontalHeaderItem(1, new QTableWidgetItem( tr("Replacement")));
	Table3->setSortingEnabled(false);
	Table3->setSelectionBehavior( QAbstractItemView::SelectRows );
	QHeaderView *header = Table3->horizontalHeader();
	header->setMovable(false);
	header->setClickable(false);
	header->setResizeMode(QHeaderView::Stretch);
	Table3->verticalHeader()->hide();
	Table3->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
	tabLayout->addWidget( Table3 );
	Layout2a = new QHBoxLayout;
	Layout2a->setMargin(0);
	Layout2a->setSpacing(5);
	QSpacerItem* spacer1 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
	Layout2a->addItem( spacer1 );
	DelB = new QPushButton( tr( "&Delete" ), tab );
	DelB->setEnabled(false);
	Layout2a->addWidget( DelB );
	QSpacerItem* spacer2 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
	Layout2a->addItem( spacer2 );
	tabLayout->addLayout( Layout2a );
	addTab( tab, tr( "Font &Substitutions" ) );

	tab3 = new QWidget( this );
	tab3Layout = new QHBoxLayout( tab3 );
	tab3Layout->setMargin(10);
	tab3Layout->setSpacing(5);
	// If we're being called for global application preferences, not document
	// preferences, we let the user customize font search paths. Because things
	// go rather badly if paths are changed/removed while a doc is open, the
	// control is also not displayed if there is a document open.
	if (!DocAvail && !ScCore->primaryMainWindow()->HaveDoc)
	{
		PathList = new QListWidget( tab3 );
		readPaths();
		PathList->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
		tab3Layout->addWidget( PathList );
		LayoutR = new QVBoxLayout;
		LayoutR->setMargin(0);
		LayoutR->setSpacing(5);
		ChangeB = new QPushButton( tr( "C&hange..." ), tab3 );
		LayoutR->addWidget( ChangeB );
		AddB = new QPushButton( tr( "A&dd..." ), tab3 );
		LayoutR->addWidget( AddB );
		RemoveB = new QPushButton( tr( "&Remove" ), tab3 );
		LayoutR->addWidget( RemoveB );
		QSpacerItem* spacer_2 = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding );
		LayoutR->addItem( spacer_2 );
		tab3Layout->addLayout( LayoutR );
		ChangeB->setEnabled(false);
		RemoveB->setEnabled(false);
		connect(PathList, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(SelectPath(QListWidgetItem*)));
		connect(AddB, SIGNAL(clicked()), this, SLOT(AddPath()));
		connect(ChangeB, SIGNAL(clicked()), this, SLOT(ChangePath()));
		connect(RemoveB, SIGNAL(clicked()), this, SLOT(DelPath()));
	}
Exemple #17
0
/**
 * Build a path from #_path_builder xpos/ypos to the mouse cursor position.
 * @param mousexy Mouse position.
 */
void PathBuildManager::ComputeNewLongPath(const Point32 &mousexy)
{
	static const TrackSlope slope_prios_down[] = {TSL_DOWN, TSL_FLAT, TSL_UP,   TSL_INVALID}; // Order of preference when going down.
	static const TrackSlope slope_prios_flat[] = {TSL_FLAT, TSL_UP,   TSL_DOWN, TSL_INVALID}; // Order of preference when at the right height.
	static const TrackSlope slope_prios_up[]   = {TSL_UP,   TSL_FLAT, TSL_DOWN, TSL_INVALID}; // Order of preference when going up.

	Viewport *vp = GetViewport();
	if (vp == nullptr) return;

	int c1, c2, c3;
	switch (vp->orientation) {
		case VOR_NORTH: c1 =  1; c2 =  2; c3 =  2; break;
		case VOR_EAST:  c1 = -1; c2 = -2; c3 =  2; break;
		case VOR_SOUTH: c1 =  1; c2 = -2; c3 = -2; break;
		case VOR_WEST:  c1 = -1; c2 =  2; c3 = -2; break;
		default: NOT_REACHED();
	}

	XYZPoint16 path_pos(0, 0, 0);
	path_pos.y = this->pos.y * 256 + 128;
	int32 lambda_y = path_pos.y - mousexy.y; // Distance to constant Y plane at current tile cursor.
	path_pos.x = this->pos.x * 256 + 128;
	int32 lambda_x = path_pos.x - mousexy.x; // Distance to constant X plane at current tile cursor.

	if (abs(lambda_x) < abs(lambda_y)) {
		/* X constant. */
		path_pos.x /= 256;
		path_pos.y = Clamp<int32>(mousexy.y + c1 * lambda_x, 0, _world.GetYSize() * 256 - 1) / 256;
		path_pos.z = Clamp<int32>(vp->view_pos.z + c3 * lambda_x, 0, WORLD_Z_SIZE * 256 - 1) / 256;
	} else {
		/* Y constant. */
		path_pos.x = Clamp<int32>(mousexy.x + c1 * lambda_y, 0, _world.GetXSize() * 256 - 1) / 256;
		path_pos.y /= 256;
		path_pos.z = Clamp<int32>(vp->view_pos.z + c2 * lambda_y, 0, WORLD_Z_SIZE * 256 - 1) / 256;
	}

	if (this->long_pos != path_pos) {
		this->long_pos = path_pos;

		_additions.Clear();
		path_pos = this->pos;
		/* Find the right direction from the selected tile to the current cursor location. */
		TileEdge direction;
		Point16 dxy;
		for (direction = EDGE_BEGIN; direction < EDGE_COUNT; direction++) {
			dxy = _tile_dxy[direction];
			if (!GoodDirection(dxy.x, path_pos.x, this->long_pos.x) || !GoodDirection(dxy.y, path_pos.y, this->long_pos.y)) continue;
			break;
		}
		if (direction == EDGE_COUNT) return;

		/* 'Walk' to the cursor as long as possible. */
		while (path_pos.x != this->long_pos.x || path_pos.y != this->long_pos.y) {
			uint8 slopes = CanBuildPathFromEdge(path_pos, direction);
			const TrackSlope *slope_prio;
			/* Get order of slope preference. */
			if (path_pos.z > this->long_pos.z) {
				slope_prio = slope_prios_down;
			} else if (path_pos.z == this->long_pos.z) {
				slope_prio = slope_prios_flat;
			} else {
				slope_prio = slope_prios_up;
			}
			/* Find best slope, and take it. */
			while (*slope_prio != TSL_INVALID && (slopes & (1 << *slope_prio)) == 0) slope_prio++;
			if (*slope_prio == TSL_INVALID) break;

			path_pos.x += dxy.x;
			path_pos.y += dxy.y;

			const Voxel *v = _world.GetVoxel(path_pos);
			if (v != nullptr && HasValidPath(v)) {
				if (!ChangePath(path_pos, this->path_type, false)) break;

				if (*slope_prio == TSL_UP) path_pos.z++;
			} else {
				if (*slope_prio == TSL_UP) {
					if (!BuildUpwardPath(path_pos, static_cast<TileEdge>((direction + 2) & 3), this->path_type, false)) break;
					path_pos.z++;
				} else if (*slope_prio == TSL_DOWN) {
					v = _world.GetVoxel(path_pos + XYZPoint16(0, 0, -1));

					if (v != nullptr && HasValidPath(v)) {
						if (!ChangePath(path_pos + XYZPoint16(0, 0, -1), this->path_type, false)) break;
					} else {
						if (!BuildDownwardPath(path_pos, static_cast<TileEdge>((direction + 2) & 3), this->path_type, false)) break;
					}
					path_pos.z--;
				} else {
					if (!BuildFlatPath(path_pos, this->path_type, false)) break;
				}
			}
		}
		vp->EnableWorldAdditions();
		vp->EnsureAdditionsAreVisible();
	}
}
void CMemcardManager::CreateGUIControls()
{
	// Create the controls for both memcards

	const char* ARROW[2] = { "<-", "->" };

	m_ConvertToGci = new wxButton(this, ID_CONVERTTOGCI, _("Convert to GCI"));

	wxStaticBoxSizer *sMemcard[2];

	for (int slot = SLOT_A; slot <= SLOT_B; slot++)
	{
		m_CopyFrom[slot]    = new wxButton(this, ID_COPYFROM_A + slot,
			wxString::Format(_("%1$sCopy%1$s"), ARROW[slot ? 0 : 1]));
		m_SaveImport[slot]  = new wxButton(this, ID_SAVEIMPORT_A + slot,
			wxString::Format(_("%sImport GCI%s"), ARROWS));
		m_SaveExport[slot]  = new wxButton(this, ID_SAVEEXPORT_A + slot,
			wxString::Format(_("%sExport GCI%s"), ARROWS));
		m_Delete[slot]      = new wxButton(this, ID_DELETE_A + slot,
			wxString::Format(_("%sDelete%s"), ARROWS));


		m_PrevPage[slot] = new wxButton(this, ID_PREVPAGE_A + slot, _("Prev Page"));
		m_NextPage[slot] = new wxButton(this, ID_NEXTPAGE_A + slot, _("Next Page"));

		t_Status[slot] = new wxStaticText(this, 0, wxEmptyString, wxDefaultPosition,wxDefaultSize, 0, wxEmptyString);

		wxBoxSizer * const sPages = new wxBoxSizer(wxHORIZONTAL);
		sPages->Add(m_PrevPage[slot], 0, wxEXPAND|wxALL, 1);
		sPages->Add(t_Status[slot],0, wxEXPAND|wxALL, 5);
		sPages->Add(0, 0, 1, wxEXPAND|wxALL, 0);
		sPages->Add(m_NextPage[slot], 0, wxEXPAND|wxALL, 1);

		m_MemcardPath[slot] = new wxFilePickerCtrl(this, ID_MEMCARDPATH_A + slot,
			 StrToWxStr(File::GetUserPath(D_GCUSER_IDX)), _("Choose a memory card:"),
		_("GameCube Memory Cards (*.raw,*.gcp)") + wxString("|*.raw;*.gcp"), wxDefaultPosition, wxDefaultSize, wxFLP_USE_TEXTCTRL|wxFLP_OPEN);

		m_MemcardList[slot] = new CMemcardListCtrl(this, ID_MEMCARDLIST_A + slot, wxDefaultPosition, wxSize(350,400),
		wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT | wxLC_SINGLE_SEL, mcmSettings);

		m_MemcardList[slot]->AssignImageList(new wxImageList(96,32),wxIMAGE_LIST_SMALL);

		sMemcard[slot] = new wxStaticBoxSizer(wxVERTICAL, this, _("Memory Card") + wxString::Format(" %c", 'A' + slot));
		sMemcard[slot]->Add(m_MemcardPath[slot], 0, wxEXPAND|wxALL, 5);
		sMemcard[slot]->Add(m_MemcardList[slot], 1, wxEXPAND|wxALL, 5);
		sMemcard[slot]->Add(sPages, 0, wxEXPAND|wxALL, 1);
	}

	wxBoxSizer * const sButtons = new wxBoxSizer(wxVERTICAL);
	sButtons->AddStretchSpacer(2);
	sButtons->Add(m_CopyFrom[SLOT_B], 0, wxEXPAND, 5);
	sButtons->Add(m_CopyFrom[SLOT_A], 0, wxEXPAND, 5);
	sButtons->AddStretchSpacer(1);
	sButtons->Add(m_SaveImport[SLOT_A], 0, wxEXPAND, 5);
	sButtons->Add(m_SaveExport[SLOT_A], 0, wxEXPAND, 5);
	sButtons->AddStretchSpacer(1);
	sButtons->Add(m_ConvertToGci, 0, wxEXPAND, 5);
	sButtons->AddStretchSpacer(1);
	sButtons->Add(m_SaveImport[SLOT_B], 0, wxEXPAND, 5);
	sButtons->Add(m_SaveExport[SLOT_B], 0, wxEXPAND, 5);
	sButtons->AddStretchSpacer(1);
	sButtons->Add(m_Delete[SLOT_A], 0, wxEXPAND, 5);
	sButtons->Add(m_Delete[SLOT_B], 0, wxEXPAND, 5);
	sButtons->AddStretchSpacer();
	sButtons->Add(new wxButton(this, wxID_OK, _("Close")), 0, wxEXPAND, 5);
	sButtons->AddStretchSpacer();

	wxBoxSizer * const sMain = new wxBoxSizer(wxHORIZONTAL);
	sMain->Add(sMemcard[SLOT_A], 1, wxEXPAND|wxALL, 5);
	sMain->Add(sButtons, 0, wxEXPAND, 0);
	sMain->Add(sMemcard[SLOT_B], 1, wxEXPAND|wxALL, 5);

	SetSizerAndFit(sMain);
	Center();

	for (int i = SLOT_A; i <= SLOT_B; i++)
	{
		m_PrevPage[i]->Disable();
		m_NextPage[i]->Disable();
		m_CopyFrom[i]->Disable();
		m_SaveImport[i]->Disable();
		m_SaveExport[i]->Disable();
		m_Delete[i]->Disable();
		if (DefaultMemcard[i].length())
		{
			m_MemcardPath[i]->SetPath(StrToWxStr(DefaultMemcard[i]));
			ChangePath(i);
		}
	}
}
void CMemcardManager::OnPathChange(wxFileDirPickerEvent& event)
{
	ChangePath(event.GetId() - ID_MEMCARDPATH_A);
}
int CustomPathsSM::GetMenuInternal()
{
	int ret = optionBrowser->GetClickedOption();

	if (ret < 0)
		return MENU_NONE;

	int Idx = -1;

	//! Settings: 3D Cover Path
	if (ret == ++Idx)
	{
		titleTxt->SetText(tr( "3D Cover Path" ));
		ChangePath(Settings.covers_path, sizeof(Settings.covers_path));
	}

	//! Settings: 2D Cover Path
	else if (ret == ++Idx)
	{
		titleTxt->SetText(tr( "2D Cover Path" ));
		ChangePath(Settings.covers2d_path, sizeof(Settings.covers2d_path));
	}

	//! Settings: Full Cover Path
	else if (ret == ++Idx)
	{
		titleTxt->SetText(tr( "Full Cover Path" ));
		ChangePath(Settings.coversFull_path, sizeof(Settings.coversFull_path));
	}

	//! Settings: Disc Artwork Path
	else if (ret == ++Idx)
	{
		titleTxt->SetText(tr( "Disc Artwork Path" ));
		ChangePath(Settings.disc_path, sizeof(Settings.disc_path));
	}

	//! Settings: Theme Path
	else if (ret == ++Idx)
	{
		titleTxt->SetText(tr( "Theme Path" ));
		ChangePath(Settings.theme_path, sizeof(Settings.theme_path));
	}

	//! Settings: Titles Path
	else if (ret == ++Idx)
	{
		char oldPath[100];
		strncpy(oldPath, Settings.titlestxt_path, sizeof(Settings.titlestxt_path));

		titleTxt->SetText(tr("Titles Path"));
		if (ChangePath(Settings.titlestxt_path, sizeof(Settings.titlestxt_path)))
		{
			if(strlen(oldPath) != strlen(Settings.titlestxt_path) || strcmp(oldPath, Settings.titlestxt_path) != 0)
			{
				if (WindowPrompt(tr("Move File"), tr("Do you want to move the file(s)? Any existing ones will be deleted!"), tr("Yes"), tr("Cancel")) == 1)
				{
					MoveDbFile(oldPath, Settings.titlestxt_path, "wiitdb.xml");
					MoveDbFile(oldPath, Settings.titlestxt_path, "TitlesCache.bin");
					MoveDbFile(oldPath, Settings.titlestxt_path, "wiitdb_offsets.bin");
					MoveDbFile(oldPath, Settings.titlestxt_path, "GameTimestamps.txt");
				
					WindowPrompt(tr("Process finished."), 0, tr("OK"));
				}
			}
		}
	}

	//! Settings: Update Path
	else if (ret == ++Idx)
	{
		titleTxt->SetText(tr( "Update Path" ));
		ChangePath(Settings.update_path, sizeof(Settings.update_path));
	}

	//! Settings: GCT Cheatcodes Path
	else if (ret == ++Idx)
	{
		titleTxt->SetText(tr( "GCT Cheatcodes Path" ));
		ChangePath(Settings.Cheatcodespath, sizeof(Settings.Cheatcodespath));
	}

	//! Settings: TXT Cheatcodes Path
	else if (ret == ++Idx)
	{
		titleTxt->SetText(tr( "TXT Cheatcodes Path" ));
		ChangePath(Settings.TxtCheatcodespath, sizeof(Settings.TxtCheatcodespath));
	}

	//! Settings: DOL Path
	else if (ret == ++Idx)
	{
		titleTxt->SetText(tr( "DOL Path" ));
		ChangePath(Settings.dolpath, sizeof(Settings.dolpath));
	}

	//! Settings: Homebrew Apps Path
	else if (ret == ++Idx)
	{
		titleTxt->SetText(tr( "Homebrew Apps Path" ));
		ChangePath(Settings.homebrewapps_path, sizeof(Settings.homebrewapps_path));
	}

	//! Settings: BCA Codes Path
	else if (ret == ++Idx)
	{
		titleTxt->SetText(tr( "BCA Codes Path" ));
		ChangePath(Settings.BcaCodepath, sizeof(Settings.BcaCodepath));
	}

	//! Settings: WIP Patches Path
	else if (ret == ++Idx)
	{
		titleTxt->SetText(tr( "WIP Patches Path" ));
		ChangePath(Settings.WipCodepath, sizeof(Settings.WipCodepath));
	}

	//! Settings: Languagefiles Path
	else if (ret == ++Idx)
	{
		titleTxt->SetText(tr( "Languagefiles Path" ));
		ChangePath(Settings.languagefiles_path, sizeof(Settings.languagefiles_path));
	}

	//! Settings: WDM Files Path
	else if (ret == ++Idx)
	{
		titleTxt->SetText(tr( "WDM Files Path" ));
		ChangePath(Settings.WDMpath, sizeof(Settings.WDMpath));
	}

	//! Settings: Wiinnertag Path
	else if (ret == ++Idx)
	{
		titleTxt->SetText(tr( "Wiinnertag Path" ));
		ChangePath(Settings.WiinnertagPath, sizeof(Settings.WiinnertagPath));
	}

	//! Settings: Nand Emu Path
	else if (ret == ++Idx)
	{
		char oldPath[sizeof(Settings.NandEmuPath)];
		snprintf(oldPath, sizeof(oldPath), Settings.NandEmuPath);

		titleTxt->SetText(tr( "Nand Emu Path" ));
		ChangePath(Settings.NandEmuPath, sizeof(Settings.NandEmuPath));
		if(strncasecmp(DeviceHandler::PathToFSName(Settings.NandEmuPath), "FAT", 3) != 0)
		{
			snprintf(Settings.NandEmuPath, sizeof(Settings.NandEmuPath), oldPath);
			WindowPrompt(tr("Error:"), tr("Nand Emulation only works on FAT/FAT32 partitions!"), tr("OK"));
		}
	}

	//! Settings: Nand Emu Channel Path
	else if (ret == ++Idx)
	{
		char oldPath[sizeof(Settings.NandEmuChanPath)];
		snprintf(oldPath, sizeof(oldPath), Settings.NandEmuChanPath);

		titleTxt->SetText(tr( "Nand Emu Channel Path" ));
		int result = ChangePath(Settings.NandEmuChanPath, sizeof(Settings.NandEmuChanPath));
		if(strncasecmp(DeviceHandler::PathToFSName(Settings.NandEmuChanPath), "FAT", 3) != 0)
		{
			snprintf(Settings.NandEmuChanPath, sizeof(Settings.NandEmuChanPath), oldPath);
			WindowPrompt(tr("Error:"), tr("Nand Emulation only works on FAT/FAT32 partitions!"), tr("OK"));
		}
		else if(result == 1)
		{
			Channels::Instance()->GetEmuChannelList();
		}
	}

	//! Settings: GameCube Games Path
	else if (ret == ++Idx)
	{
		titleTxt->SetText(tr( "Main GameCube Games Path" ));
		if(ChangePath(Settings.GameCubePath, sizeof(Settings.GameCubePath)))
		{
			GCGames::Instance()->LoadAllGames();
		}
	}

	//! Settings: SD GameCube Games Path
	else if (ret == ++Idx)
	{
		char tmp_path[sizeof(Settings.GameCubeSDPath)];
		snprintf(tmp_path, sizeof(tmp_path), "%s", Settings.GameCubeSDPath);

		titleTxt->SetText(tr( "SD GameCube Games Path" ));
		if(ChangePath(tmp_path, sizeof(tmp_path)))
		{
			if(strncmp(tmp_path, "sd", 2) != 0)
			{
				WindowPrompt(tr("Error:"), tr("This path must be on SD!"), tr("OK"));
			}
			else
			{
				snprintf(Settings.GameCubeSDPath, sizeof(Settings.GameCubeSDPath), "%s", tmp_path);
				GCGames::Instance()->LoadAllGames();
			}
		}
	}

	//! Settings: GameCube Devolution loader.bin path
	else if (ret == ++Idx)
	{
		titleTxt->SetText(tr( "Devolution Loader Path" ));
		ChangePath(Settings.DEVOLoaderPath, sizeof(Settings.DEVOLoaderPath));
	}

	//! Settings: GameCube Nintendont boot.dol path
	else if (ret == ++Idx)
	{
		titleTxt->SetText(tr( "Nintendont Loader Path" ));
		ChangePath(Settings.NINLoaderPath, sizeof(Settings.NINLoaderPath));
	}

	//! Settings: Cache BNR Files Path
	else if (ret == ++Idx)
	{
		titleTxt->SetText(tr( "Cache BNR Files Path" ));
		ChangePath(Settings.BNRCachePath, sizeof(Settings.BNRCachePath));
	}

	//! Global set back of the titleTxt after a change
	titleTxt->SetText(tr( "Custom Paths" ));
	SetOptionValues();

	return MENU_NONE;
}