Skip to content

Commit

Permalink
improved user experience
Browse files Browse the repository at this point in the history
  • Loading branch information
henrykorir committed Jun 11, 2024
1 parent 085d8e7 commit 89f7b63
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 23 deletions.
Binary file modified bin/Debug/minesweeper
Binary file not shown.
26 changes: 17 additions & 9 deletions minesweeper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ wxEND_EVENT_TABLE()
MainFrame::MainFrame(const wxString &title)
: wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxMINIMIZE_BOX)
{
SetIcon(wxIcon("logo.png",wxBITMAP_TYPE_PNG , -1,-1));
SetIcon(wxIcon("logo.png",wxBITMAP_TYPE_PNG, -1,-1));
m_timer = new wxTimer(this, TIMER_ID);
m_timer->Start(1000);

Expand All @@ -30,9 +30,9 @@ MainFrame::MainFrame(const wxString &title)
wxBitmap clock(clock_xpm);
wxBitmap::Rescale(clock, wxSize(32,32));
wxStaticBitmap* staticBitmap = new wxStaticBitmap(topPanel, wxID_STATIC,clock);
wxUnusedVar(staticBitmap);
dashSizer->Add(topPanel);


int id = 0;

for (int x = 0; x < 9; x++)
Expand All @@ -50,8 +50,8 @@ MainFrame::MainFrame(const wxString &title)
}
}

topSizer->Add(dashSizer);//, 0, wxALIGN_CENTER_HORIZONTAL | wxALL,4);
topSizer->Add(gridSizer);//, 0, wxALIGN_CENTER | wxALL, 4);
topSizer->Add(dashSizer, 0, wxALIGN_CENTER_HORIZONTAL);// | wxALL,4);
topSizer->Add(gridSizer, 0, wxALIGN_CENTER);// | wxALL, 4);
topSizer->Fit(this);
topSizer->SetSizeHints(this);

Expand Down Expand Up @@ -146,8 +146,12 @@ void MainFrame::UnCover(int x, int y)

wxAnyButton * button = matrix[x][y]->GetButton();
button->SetFont(wxFont(13, wxFONTFAMILY_ROMAN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false));
button->SetLabel(wxString::Format("%d", countMines));
//button->Enable(false);

if(countMines>0)button->SetLabel(wxString::Format("%d", countMines));
Field* field = matrix[x][y];
if(countMines == 0)
field->SetBackgroundColour(wxColor(254,254,254));

visited[matrix[x][y]->GetID()] = true;

while (lh.size() > 0 && countMines == 0)
Expand All @@ -173,8 +177,8 @@ void MainFrame::UnCover(int x, int y)

void MainFrame::Reveal()
{
int width = 9;
for(long unsigned int i = 0; i < minesLoci.size(); i++)
size_t width = 9, numberOfFields = 81;
for(size_t i = 0; i < minesLoci.size(); i++)
{
int index = minesLoci[i];
wxAnyButton * button = matrix[index / width][index % width]->GetButton();
Expand All @@ -184,7 +188,11 @@ void MainFrame::Reveal()
//button->SetBitmap(mine, wxLEFT);
//button->Disable();
}
SetWindowStyle(wxWS_EX_BLOCK_EVENTS);

for(size_t idx = 0; idx < numberOfFields; idx++)
{
dynamic_cast<wxWindow *>(matrix[idx / numberOfFields][idx % numberOfFields])->Disable();
}
}

void MainFrame::OnTimer(wxTimerEvent& event)
Expand Down
4 changes: 2 additions & 2 deletions minesweeper.depend
Original file line number Diff line number Diff line change
Expand Up @@ -1631,7 +1631,7 @@
1714995324 source:/home/freedom/Desktop/work/minesweeper/minesweeper/minesweeper.cpp
"wx/wx.h"

1717968310 source:/home/freedom/Desktop/work/minesweeper/minesweeper.cpp
1718137156 source:/home/freedom/Desktop/work/minesweeper/minesweeper.cpp
"wx/wx.h"
<stdlib.h>
<vector>
Expand All @@ -1640,7 +1640,7 @@
"red.xpm"
"clock.xpm"

1717966564 source:/home/freedom/Desktop/work/minesweeper/field.cpp
1717969445 source:/home/freedom/Desktop/work/minesweeper/field.cpp
"wx/wx.h"
"field.h"
"minesweeper.h"
Expand Down
24 changes: 12 additions & 12 deletions minesweeper.layout
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,34 @@
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Debug" />
<File name="minesweeper.cpp" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="-3" zoom_2="0">
<File name="field.cpp" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="5" zoom_2="0">
<Cursor>
<Cursor1 position="4355" topLine="142" />
<Cursor1 position="257" topLine="0" />
</Cursor>
</File>
<File name="field.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="red.xpm" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="19" topLine="0" />
<Cursor1 position="93" topLine="0" />
</Cursor>
</File>
<File name="field.cpp" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="clock.xpm" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="345" topLine="44" />
<Cursor1 position="109" topLine="0" />
</Cursor>
</File>
<File name="red.xpm" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="field.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="93" topLine="0" />
<Cursor1 position="19" topLine="0" />
</Cursor>
</File>
<File name="minesweeper.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="minesweeper.cpp" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="7" zoom_2="0">
<Cursor>
<Cursor1 position="518" topLine="18" />
<Cursor1 position="1174" topLine="29" />
</Cursor>
</File>
<File name="clock.xpm" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="minesweeper.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="109" topLine="0" />
<Cursor1 position="518" topLine="18" />
</Cursor>
</File>
</CodeBlocks_layout_file>

0 comments on commit 89f7b63

Please sign in to comment.