Some code refactoring
This commit is contained in:
@@ -60,20 +60,21 @@ void generateWordInfo(GridType &grid, std::vector<WordInfo> &winfos){
|
|||||||
bool exist = false;
|
bool exist = false;
|
||||||
for (size_t j = 0; j < grid.at(0).size(); ++j){
|
for (size_t j = 0; j < grid.at(0).size(); ++j){
|
||||||
for (size_t i = 0; i < grid.size(); ++i){
|
for (size_t i = 0; i < grid.size(); ++i){
|
||||||
if (grid.at(i).at(j) == CELL_CLEAR){
|
if ( grid.at(i).at(j) == CELL_CLEAR ){
|
||||||
if (((j == 0) || (grid.at(i).at(j - 1) != CELL_CLEAR)) &&
|
if ( ((j == 0) || (grid.at(i).at(j - 1) != CELL_CLEAR)) &&
|
||||||
(j != grid.at(0).size() - 1))
|
(j != grid.at(0).size() - 1) )
|
||||||
if (grid.at(i).at(j+1) == CELL_CLEAR){
|
if ( grid.at(i).at(j+1) == CELL_CLEAR ){
|
||||||
size_t cur_len = 1;
|
size_t cur_len = 1;
|
||||||
bool cont = true;
|
bool cont = true;
|
||||||
while ((j + cur_len < grid.at(0).size()) && cont){
|
while ( (j + cur_len < grid.at(0).size()) && cont ){
|
||||||
++cur_len;
|
++cur_len;
|
||||||
if (grid.at(i).at(j+cur_len-1) != CELL_CLEAR){
|
if ( grid.at(i).at(j+cur_len-1) != CELL_CLEAR ){
|
||||||
cont = false;
|
cont = false;
|
||||||
--cur_len;
|
--cur_len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exist = true;
|
exist = true;
|
||||||
|
|
||||||
WordInfo t;
|
WordInfo t;
|
||||||
t.x = i;
|
t.x = i;
|
||||||
t.y = j;
|
t.y = j;
|
||||||
@@ -83,16 +84,16 @@ void generateWordInfo(GridType &grid, std::vector<WordInfo> &winfos){
|
|||||||
winfos.push_back(t);
|
winfos.push_back(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((i ==0) || (grid.at(i - 1).at(j) != CELL_CLEAR)) &&
|
if ( ((i ==0) || (grid.at(i - 1).at(j) != CELL_CLEAR)) &&
|
||||||
(i != grid.size() - 1))
|
(i != grid.size() - 1) )
|
||||||
if (grid.at(i + 1).at(j) == CELL_CLEAR){
|
if ( grid.at(i + 1).at(j) == CELL_CLEAR ){
|
||||||
size_t cur_len = 1;
|
size_t cur_len = 1;
|
||||||
bool cont = true;
|
bool cont = true;
|
||||||
while ((i + cur_len < grid.size()) && cont){
|
while ((i + cur_len < grid.size()) && cont){
|
||||||
++cur_len;
|
++cur_len;
|
||||||
if (grid.at(i+cur_len-1).at(j) != CELL_CLEAR){
|
if (grid.at(i+cur_len-1).at(j) != CELL_CLEAR){
|
||||||
cont = false;
|
cont = false;
|
||||||
cur_len--;
|
--cur_len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exist = true;
|
exist = true;
|
||||||
@@ -104,7 +105,7 @@ void generateWordInfo(GridType &grid, std::vector<WordInfo> &winfos){
|
|||||||
t.direct = true;
|
t.direct = true;
|
||||||
winfos.push_back(t);
|
winfos.push_back(t);
|
||||||
}
|
}
|
||||||
if (exist){
|
if ( exist ){
|
||||||
exist = false;
|
exist = false;
|
||||||
++cur_ind;
|
++cur_ind;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,12 +68,12 @@ void MainFrame::OnbtnPathClick(wxCommandEvent &event) {
|
|||||||
wxFileDialog dlgOpen(this, wxT("Открыть файл кроссворда"), wxEmptyString, wxEmptyString,
|
wxFileDialog dlgOpen(this, wxT("Открыть файл кроссворда"), wxEmptyString, wxEmptyString,
|
||||||
wxT("Файлы кроссворда (*.cross)|*.cross"), wxFD_OPEN|wxFD_FILE_MUST_EXIST);
|
wxT("Файлы кроссворда (*.cross)|*.cross"), wxFD_OPEN|wxFD_FILE_MUST_EXIST);
|
||||||
|
|
||||||
if (dlgOpen.ShowModal() == wxID_CANCEL)
|
if ( dlgOpen.ShowModal() == wxID_CANCEL )
|
||||||
return;
|
return;
|
||||||
// proceed loading the file chosen by the user;
|
// proceed loading the file chosen by the user;
|
||||||
// this can be done with e.g. wxWidgets input streams:
|
// this can be done with e.g. wxWidgets input streams:
|
||||||
wxFileInputStream input_stream(dlgOpen.GetPath());
|
wxFileInputStream input_stream(dlgOpen.GetPath());
|
||||||
if (!input_stream.IsOk()) {
|
if ( !input_stream.IsOk() ) {
|
||||||
wxLogError(wxT("Cannot open file ")+dlgOpen.GetPath());
|
wxLogError(wxT("Cannot open file ")+dlgOpen.GetPath());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user