mirror of
https://gitee.com/yanmu_ym/cpp.git
synced 2026-02-03 09:33:16 +08:00
36 lines
752 B
C++
36 lines
752 B
C++
#include "scene.h"
|
|
#include "command.h"
|
|
|
|
CCommand::CCommand(CScene *pOwner) : _pOwner(pOwner)
|
|
{}
|
|
|
|
CCommand::CCommand(CScene *pOwner, const point_t &point, int preValue, int curValue)
|
|
: _pOwner(pOwner), _stPoint(point), _nPreValue(preValue), _nCurValue(curValue) {}
|
|
|
|
CCommand::CCommand(const CCommand &rhs)
|
|
: _pOwner(rhs._pOwner)
|
|
, _stPoint(rhs._stPoint)
|
|
, _nPreValue(rhs._nPreValue)
|
|
, _nCurValue(rhs._nCurValue)
|
|
{}
|
|
|
|
CCommand::~CCommand(){}
|
|
|
|
bool CCommand::execute(int nInputValue)
|
|
{
|
|
if (!_pOwner)
|
|
return false;
|
|
|
|
_stPoint = _pOwner->getCurPoint();
|
|
return _pOwner->setCurValue(nInputValue, _nPreValue);
|
|
}
|
|
|
|
void CCommand::undo()
|
|
{
|
|
if (_pOwner)
|
|
{
|
|
_pOwner->setPointValue(_stPoint, _nPreValue);
|
|
}
|
|
|
|
return;
|
|
} |