-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCopyObjectAction.cpp
More file actions
36 lines (29 loc) · 1.07 KB
/
Copy pathCopyObjectAction.cpp
File metadata and controls
36 lines (29 loc) · 1.07 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
#include "CopyObjectAction.h"
#include "GameObject.h"
CopyObjectAction::CopyObjectAction(ApplicationManager* pApp) : Action(pApp) {
cellToCopy = nullptr;
}
bool CopyObjectAction::ReadActionParameters() {
Grid* pGrid = pManager->GetGrid();
Output* pOut = pGrid->GetOutput();
Input* pIn = pGrid->GetInput();
pOut->PrintMessage("Copy Object: Click on the cell to copy its object ...");
cellToCopy = pGrid->GetCell(pIn->GetCellClicked());
if (!cellToCopy) {
pGrid->PrintErrorMessage("Error: Invalid cell selected! Click to continue ...");
pIn->GetCellClicked(); pOut->ClearStatusBar(); return false;
}
if (!cellToCopy->GetGameObject()) {
pGrid->PrintErrorMessage("Error: No object in the selected cell! Click to continue ...");
pIn->GetCellClicked(); pOut->ClearStatusBar(); return false;
}
pOut->ClearStatusBar();
return true;
}
void CopyObjectAction::Execute() {
if (!ReadActionParameters()) return;
Grid* pGrid = pManager->GetGrid();
GameObject* gameObj = cellToCopy->GetGameObject();
pGrid->SetClipboard(gameObj->Clone());
}
CopyObjectAction::~CopyObjectAction() {}