-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainForm.cpp
More file actions
87 lines (85 loc) · 2.81 KB
/
Copy pathMainForm.cpp
File metadata and controls
87 lines (85 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include "MainForm.h"
#include <msclr/marshal_cppstd.h>
#include <string>
#include "GameForm.h"
#include "GameUser.h"
#include "AboutForm.h"
namespace szablon {
MainForm::MainForm(void) {
InitializeComponent();
}
void MainForm::difficultyBar_Scroll(System::Object^ sender, System::EventArgs^ e){
std::string difficulty = "";
int diff = this->trackBar1->Value;
if (diff >= 70) difficulty = "HardCore";
else if (diff >= 60) difficulty = "Hard";
else if (diff >= 50) difficulty = "Advanced";
else if (diff >= 40) difficulty = "Medium";
else if (diff >= 30) difficulty = "Normal";
else if (diff >= 20) difficulty = "Easy";
else if (diff >= 10) difficulty = "Beginner";
else difficulty = "Peaceful";
this->groupBox2->Text = gcnew System::String(difficulty.c_str());
}
void MainForm::start_button_Click(System::Object^ sender, System::EventArgs^ e)
{
if (!this->readyToPlay) {
System::String^ message = "Kliknij w 'stats', \nAby za³adowaæ statystki i rozegraæ grê";
MessageBox::Show(message,"START",MessageBoxButtons::OK,MessageBoxIcon::Information);
return;
}
std::string name = msclr::interop::marshal_as<std::string>(this->textBox1->Text);
std::string difficulty = msclr::interop::marshal_as<std::string>(this->groupBox2->Text);
int digitsDifficulty = this->trackBar1->Value;
if (this->gameform != nullptr) {
this->gameform->Close();
this->gameform = nullptr;
}
GameUser* gameuser = this->gameStats->getGameUser(name);
if (!gameuser) {
gameuser = new GameUser(name, 0, 0, difficulty, false);
}else {
gameuser->setDifficulty(difficulty);
}
this->gameform = gcnew GameForm(gameuser, difficulty, digitsDifficulty, this->gameStats);
this->gameform->Show();
}
void MainForm::clearToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
this->readyToPlay = false;
this->gameStats = nullptr;
this->textBox1->Text = "Patryk Pszeniczny";
this->trackBar1->Value = 1;
this->groupBox2->Text = L"Peaceful";
if (this->gameform != nullptr) {
this->gameform->Close();
this->gameform = nullptr;
}
}
void MainForm::exitToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
this->Close();
}
void MainForm::aboutToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
AboutForm^ aboutForm = gcnew AboutForm();
aboutForm->Show();
}
void MainForm::statsToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
this->gameStats = new GameStats();
this->readyToPlay = gameStats->openDialogFile();
}
void MainForm::setGameStats(GameStats* gamestats) {
this->gameStats = gamestats;
}
GameStats* MainForm::getGameStats() {
return this->gameStats;
}
void MainForm::setReadyToPlay(bool value) {
this->readyToPlay = value;
}
bool MainForm::getReadyToPlay() {
return this->readyToPlay;
}
}