Some codestyle changes
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
<CodeLite_Workspace Name="CrossGen" Database="">
|
||||
<Project Name="wxCrossGen" Path="wxCrossGen/wxCrossGen.project" Active="Yes"/>
|
||||
<Project Name="CrossBench" Path="CrossBench/CrossBench.project" Active="No"/>
|
||||
<Environment>
|
||||
<![CDATA[]]>
|
||||
</Environment>
|
||||
<BuildMatrix>
|
||||
<WorkspaceConfiguration Name="Debug" Selected="no">
|
||||
<Project Name="wxCrossGen" ConfigName="Debug"/>
|
||||
|
||||
8
Makefile
8
Makefile
@@ -1,8 +1,8 @@
|
||||
.PHONY: clean All
|
||||
|
||||
All:
|
||||
@echo "----------Building project:[ CrossBench - Release ]----------"
|
||||
@cd "CrossBench" && $(MAKE) -f "CrossBench.mk"
|
||||
@echo "----------Building project:[ wxCrossGen - Release ]----------"
|
||||
@cd "wxCrossGen" && $(MAKE) -f "wxCrossGen.mk"
|
||||
clean:
|
||||
@echo "----------Cleaning project:[ CrossBench - Release ]----------"
|
||||
@cd "CrossBench" && $(MAKE) -f "CrossBench.mk" clean
|
||||
@echo "----------Cleaning project:[ wxCrossGen - Release ]----------"
|
||||
@cd "wxCrossGen" && $(MAKE) -f "wxCrossGen.mk" clean
|
||||
|
||||
@@ -10,11 +10,10 @@ const uint32_t MAX_WORD_COUNT = 262144; // =2^18
|
||||
void readDict(const wxString path, DictType &dict_out){
|
||||
wxTextFile f;
|
||||
f.Open(path);
|
||||
for ( wxString str = f.GetFirstLine(); !f.Eof(); str = f.GetNextLine() ) {
|
||||
wxString key,val;
|
||||
for (wxString str = f.GetFirstLine(); !f.Eof(); str = f.GetNextLine()) {
|
||||
int del_ind = str.Index('-');
|
||||
key = str.Left(del_ind-1);
|
||||
val = str.Right(str.size() - del_ind - 2);
|
||||
wxString key = str.Left(del_ind-1);
|
||||
wxString val = str.Right(str.size() - del_ind - 2);
|
||||
dict_out[key] = val;
|
||||
}
|
||||
f.Close();
|
||||
@@ -30,12 +29,13 @@ void readGrid(const wxString path, GridType &grid){
|
||||
grid.at(i).resize(f.GetLineCount());
|
||||
|
||||
wxLogDebug(wxT("Total lines: %d. First line is %s and size = %d"),f.GetLineCount(), str.c_str(),str.size());
|
||||
for ( unsigned int i = 0; !f.Eof(); str = f.GetNextLine() ) {
|
||||
for (unsigned int i = 0; !f.Eof(); str = f.GetNextLine()){
|
||||
wxLogDebug(str);
|
||||
for (unsigned int j = 0; j < str.size(); ++j)
|
||||
grid.at(j).at(i) = str.at(j);
|
||||
++i;
|
||||
}
|
||||
|
||||
wxLogDebug(wxT("Прочитана сетка размером %d x %d"),
|
||||
static_cast<int>(grid.size()), static_cast<int>(grid.at(0).size()));
|
||||
f.Close();
|
||||
@@ -58,7 +58,6 @@ BackedCharsTransType getFromCharsTransed(const CharsTransType &char_trans){
|
||||
}
|
||||
|
||||
void toWorkGridType(const GridType &grid, WorkGridType &grid_out){
|
||||
grid_out.clear();
|
||||
grid_out.resize(grid.size());
|
||||
for (size_t i = 0; i < grid.size(); ++i){
|
||||
grid_out.at(i).resize(grid.at(0).size());
|
||||
@@ -81,7 +80,7 @@ void generateAllWords(const DictType &dict, AllWordsType &words_out,
|
||||
TransedChar st = TRANS_BORDER + 1;
|
||||
for (auto it = dict.begin(); it != dict.end(); ++it){
|
||||
if ( words_out.size() <= it->first.size() )
|
||||
words_out.resize(it->first.size() + 2);
|
||||
words_out.resize(it->first.size() + 1);
|
||||
TransedWord t_tw(it->first.size());
|
||||
for (size_t i = 0; i < it->first.size(); ++i){
|
||||
auto cur_ch = it->first.at(i);
|
||||
@@ -114,7 +113,7 @@ void generateWordInfo(const GridType &grid, std::vector<WordInfo> &winfos_out){
|
||||
(j !=y_len - 1) )
|
||||
if ( grid.at(i).at(j+1) == CELL_CLEAR ) {
|
||||
size_t cur_len = 1;
|
||||
bool cont = true;
|
||||
bool cont = true;
|
||||
while ( (j + cur_len < y_len) && cont ) {
|
||||
++cur_len;
|
||||
if ( grid.at(i).at(j+cur_len-1) != CELL_CLEAR ) {
|
||||
@@ -171,31 +170,31 @@ bool procCross(
|
||||
const size_t cur_word_ind,
|
||||
std::vector<TransedWord> &out
|
||||
){
|
||||
if (cur_word_ind == winfos.size())
|
||||
if ( cur_word_ind == winfos.size() )
|
||||
return true;
|
||||
WordInfo cur_wi = winfos.at(cur_word_ind);
|
||||
size_t rand_add = rand() % 100000;
|
||||
size_t cur_len = cur_wi.len;
|
||||
size_t cur_len = cur_wi.len;
|
||||
size_t cur_words_size = words.at(cur_len).size();
|
||||
for (size_t icw = 0; icw < cur_words_size; ++icw){
|
||||
if (used.find(getWordUniq(icw,cur_len)) != used.end())
|
||||
if ( used.find(getWordUniq(icw,cur_len)) != used.end() )
|
||||
continue;
|
||||
TransedWord cur_word = words.at(cur_len).at((icw + rand_add) % cur_words_size);
|
||||
// Показывает, можно ли записать это слово в сетку
|
||||
bool can_write = true;
|
||||
if ( cur_wi.direct == false ){
|
||||
if ( cur_wi.direct ){
|
||||
for (size_t j = 0; j < cur_wi.len; ++j)
|
||||
if ((grid.at(cur_wi.x).at(j + cur_wi.y) != TRANS_CLEAR) &&
|
||||
(grid.at(cur_wi.x).at(j + cur_wi.y) != cur_word.at(j)))
|
||||
if ( (grid.at(cur_wi.x + j).at(cur_wi.y) != TRANS_CLEAR) &&
|
||||
(grid.at(cur_wi.x + j).at(cur_wi.y) != cur_word.at(j)) )
|
||||
can_write = false;
|
||||
} else {
|
||||
for (size_t j = 0; j < cur_wi.len; ++j)
|
||||
if ((grid.at(cur_wi.x + j).at(cur_wi.y) != TRANS_CLEAR) &&
|
||||
(grid.at(cur_wi.x + j).at(cur_wi.y) != cur_word.at(j)))
|
||||
if ( (grid.at(cur_wi.x).at(j + cur_wi.y) != TRANS_CLEAR) &&
|
||||
(grid.at(cur_wi.x).at(j + cur_wi.y) != cur_word.at(j)) )
|
||||
can_write = false;
|
||||
}
|
||||
|
||||
if (can_write) {
|
||||
if ( can_write ) {
|
||||
UsedWords t_used(used);
|
||||
t_used.insert(getWordUniq(icw,cur_len));
|
||||
|
||||
@@ -234,7 +233,6 @@ void generateCross(const GridType &grid, const AllWordsType &words,
|
||||
procCross(t_used, words, grid_work, winfos, 0, words_trans_out);
|
||||
std::reverse(words_trans_out.begin(), words_trans_out.end());
|
||||
BackedCharsTransType bctt = getFromCharsTransed(trans_type);
|
||||
words_out.clear();
|
||||
words_out.resize(words_trans_out.size());
|
||||
std::transform(
|
||||
words_trans_out.begin(),
|
||||
|
||||
@@ -55,7 +55,7 @@ void MainFrame::SetGridImage(GridType &grid, size_t w) {
|
||||
|
||||
for (size_t i = 0; i < grid.size(); ++i){
|
||||
for (size_t j = 0; j < grid.at(0).size(); ++j){
|
||||
if (grid.at(i).at(j) == CELL_CLEAR)
|
||||
if ( grid.at(i).at(j) == CELL_CLEAR )
|
||||
dc.DrawRectangle(sq_w*i,sq_h*j,sq_w+1,sq_h+1);
|
||||
}
|
||||
}
|
||||
@@ -140,7 +140,7 @@ void MainFrame::onGenerateClick(wxCommandEvent &event) {
|
||||
|
||||
tOutput->AppendText(getQuesString(t_cross));
|
||||
|
||||
if (winfos.size() == 0)
|
||||
if ( winfos.size() == 0 )
|
||||
throw 42;
|
||||
SetGridImage(_grid);
|
||||
}
|
||||
@@ -152,13 +152,13 @@ void MainFrame::onGenerateClick(wxCommandEvent &event) {
|
||||
}
|
||||
|
||||
void MainFrame::onExportClick(wxCommandEvent& event) {
|
||||
if ( _grid.size() == 0 ) {
|
||||
if ( _grid.empty() ) {
|
||||
wxMessageBox( _("Grid isn't loaded now"), _("Info"), wxICON_INFORMATION );
|
||||
return;
|
||||
}
|
||||
wxFileDialog dlgSave(this, _("Exporting crossword"), wxEmptyString, wxEmptyString,
|
||||
_("txt files (*.txt)|*.txt"), wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
|
||||
if (dlgSave.ShowModal() == wxID_CANCEL)
|
||||
if ( dlgSave.ShowModal() == wxID_CANCEL )
|
||||
return;
|
||||
FilledCrossword t_cross;
|
||||
t_cross.grid = _grid;
|
||||
@@ -166,7 +166,7 @@ void MainFrame::onExportClick(wxCommandEvent& event) {
|
||||
t_cross.ques = _ques;
|
||||
generateWordInfo(_grid, t_cross.words);
|
||||
if ( !exportToFile(t_cross, dlgSave.GetPath()) ){
|
||||
wxLogError(wxT("Cannot save current contents in file '%s'."), dlgSave.GetPath().GetData());
|
||||
wxLogError(_("Cannot save current contents to file '%s'."), dlgSave.GetPath().GetData());
|
||||
return;
|
||||
}
|
||||
wxLogDebug(wxT("Exporting to ") + dlgSave.GetPath() + wxT(" is complete"));
|
||||
|
||||
@@ -13,7 +13,7 @@ CurrentFileName :=
|
||||
CurrentFilePath :=
|
||||
CurrentFileFullPath :=
|
||||
User :=Aleksey Lobanov
|
||||
Date :=20/06/15
|
||||
Date :=22/06/15
|
||||
CodeLitePath :="/home/alex/.codelite"
|
||||
LinkerName :=/usr/bin/g++-4.8
|
||||
SharedObjectLinkerName :=/usr/bin/g++-4.8 -shared -fPIC
|
||||
|
||||
Reference in New Issue
Block a user