-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpenGridAction.cpp
More file actions
55 lines (50 loc) · 1.15 KB
/
OpenGridAction.cpp
File metadata and controls
55 lines (50 loc) · 1.15 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
#include "OpenGridAction.h"
#include "Input.h"
#include "Output.h"
#include "Grid.h"
#include <string>
#include "Ladder.h"
#include "Snake.h"
#include "Card.h"
#include "fstream"
OpenGridAction::OpenGridAction(ApplicationManager *pApp) :Action(pApp)
{
// Initializes the pManager pointer of Action with the passed pointer
}
void OpenGridAction::ReadActionParameters()
{
Grid*pGrid = pManager->GetGrid();
Input *pIn = pGrid->GetInput();
Output *pOut = pGrid->GetOutput();
pOut->PrintMessage("Enter the file name to open.... ");
filename=pIn->GetSrting(pOut);
//clear statusbar
pOut->ClearStatusBar();
}
void OpenGridAction::Execute()
{
ReadActionParameters();
Grid*pGrid = pManager->GetGrid();
Output * pOut=pGrid->GetOutput();
pGrid->RemoveAllGameObject();
ifstream file;
file.open(filename+".txt");
if (file.is_open())
{
Ladder L(-1,-1);
L.Load(file,pGrid);
Snake S(-1, -1);
S.Load(file, pGrid);
Card C((-1,-1));
C.Load(file, pGrid);
pGrid->UpdateInterface();
file.close();
}
else
{
pOut->PrintMessage("the file cannot be opened.......");
}
}
OpenGridAction::~OpenGridAction()
{
}