change: rename namespace to easy2d.
This commit is contained in:
parent
2db8fc1021
commit
709f2bfe8d
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#include "..\e2daction.h"
|
#include "..\e2daction.h"
|
||||||
|
|
||||||
e2d::Action::Action()
|
easy2d::Action::Action()
|
||||||
: running_(false)
|
: running_(false)
|
||||||
, done_(false)
|
, done_(false)
|
||||||
, initialized_(false)
|
, initialized_(false)
|
||||||
|
|
@ -28,71 +28,71 @@ e2d::Action::Action()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Action::~Action()
|
easy2d::Action::~Action()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Action::IsRunning()
|
bool easy2d::Action::IsRunning()
|
||||||
{
|
{
|
||||||
return running_;
|
return running_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Action::Resume()
|
void easy2d::Action::Resume()
|
||||||
{
|
{
|
||||||
running_ = true;
|
running_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Action::Pause()
|
void easy2d::Action::Pause()
|
||||||
{
|
{
|
||||||
running_ = false;
|
running_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Action::Stop()
|
void easy2d::Action::Stop()
|
||||||
{
|
{
|
||||||
done_ = true;
|
done_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const e2d::String& e2d::Action::GetName() const
|
const easy2d::String& easy2d::Action::GetName() const
|
||||||
{
|
{
|
||||||
return name_;
|
return name_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Action::SetName(const String& name)
|
void easy2d::Action::SetName(const String& name)
|
||||||
{
|
{
|
||||||
name_ = name;
|
name_ = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Node * e2d::Action::GetTarget()
|
easy2d::Node * easy2d::Action::GetTarget()
|
||||||
{
|
{
|
||||||
return target_;
|
return target_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Action::Reset()
|
void easy2d::Action::Reset()
|
||||||
{
|
{
|
||||||
initialized_ = false;
|
initialized_ = false;
|
||||||
done_ = false;
|
done_ = false;
|
||||||
started_ = Time::Now();
|
started_ = Time::Now();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Action::IsDone() const
|
bool easy2d::Action::IsDone() const
|
||||||
{
|
{
|
||||||
return done_;
|
return done_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Action::StartWithTarget(Node* target)
|
void easy2d::Action::StartWithTarget(Node* target)
|
||||||
{
|
{
|
||||||
target_ = target;
|
target_ = target;
|
||||||
running_ = true;
|
running_ = true;
|
||||||
this->Reset();
|
this->Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Action::Init()
|
void easy2d::Action::Init()
|
||||||
{
|
{
|
||||||
initialized_ = true;
|
initialized_ = true;
|
||||||
started_ = Time::Now();
|
started_ = Time::Now();
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Action::Update()
|
void easy2d::Action::Update()
|
||||||
{
|
{
|
||||||
if (!initialized_)
|
if (!initialized_)
|
||||||
{
|
{
|
||||||
|
|
@ -100,6 +100,6 @@ void e2d::Action::Update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Action::ResetTime()
|
void easy2d::Action::ResetTime()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,30 +21,30 @@
|
||||||
#include "..\e2daction.h"
|
#include "..\e2daction.h"
|
||||||
#include "..\e2dobject.h"
|
#include "..\e2dobject.h"
|
||||||
|
|
||||||
e2d::Animate::Animate()
|
easy2d::Animate::Animate()
|
||||||
: frame_index_(0)
|
: frame_index_(0)
|
||||||
, animation_(nullptr)
|
, animation_(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Animate::Animate(Animation * animation)
|
easy2d::Animate::Animate(Animation * animation)
|
||||||
: frame_index_(0)
|
: frame_index_(0)
|
||||||
, animation_(nullptr)
|
, animation_(nullptr)
|
||||||
{
|
{
|
||||||
this->SetAnimation(animation);
|
this->SetAnimation(animation);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Animate::~Animate()
|
easy2d::Animate::~Animate()
|
||||||
{
|
{
|
||||||
SafeRelease(animation_);
|
SafeRelease(animation_);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Animation * e2d::Animate::GetAnimation() const
|
easy2d::Animation * easy2d::Animate::GetAnimation() const
|
||||||
{
|
{
|
||||||
return animation_;
|
return animation_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Animate::SetAnimation(Animation * animation)
|
void easy2d::Animate::SetAnimation(Animation * animation)
|
||||||
{
|
{
|
||||||
if (animation && animation != animation_)
|
if (animation && animation != animation_)
|
||||||
{
|
{
|
||||||
|
|
@ -58,7 +58,7 @@ void e2d::Animate::SetAnimation(Animation * animation)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Animate::Init()
|
void easy2d::Animate::Init()
|
||||||
{
|
{
|
||||||
Action::Init();
|
Action::Init();
|
||||||
|
|
||||||
|
|
@ -70,7 +70,7 @@ void e2d::Animate::Init()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Animate::Update()
|
void easy2d::Animate::Update()
|
||||||
{
|
{
|
||||||
Action::Update();
|
Action::Update();
|
||||||
|
|
||||||
|
|
@ -101,18 +101,18 @@ void e2d::Animate::Update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Animate::ResetTime()
|
void easy2d::Animate::ResetTime()
|
||||||
{
|
{
|
||||||
Action::ResetTime();
|
Action::ResetTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Animate::Reset()
|
void easy2d::Animate::Reset()
|
||||||
{
|
{
|
||||||
Action::Reset();
|
Action::Reset();
|
||||||
frame_index_ = 0;
|
frame_index_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Animate * e2d::Animate::Clone() const
|
easy2d::Animate * easy2d::Animate::Clone() const
|
||||||
{
|
{
|
||||||
if (animation_)
|
if (animation_)
|
||||||
{
|
{
|
||||||
|
|
@ -121,7 +121,7 @@ e2d::Animate * e2d::Animate::Clone() const
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Animate * e2d::Animate::Reverse() const
|
easy2d::Animate * easy2d::Animate::Reverse() const
|
||||||
{
|
{
|
||||||
if (animation_)
|
if (animation_)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -20,29 +20,29 @@
|
||||||
|
|
||||||
#include "..\e2daction.h"
|
#include "..\e2daction.h"
|
||||||
|
|
||||||
e2d::Animation::Animation()
|
easy2d::Animation::Animation()
|
||||||
: interval_(1)
|
: interval_(1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Animation::Animation(const Images& frames)
|
easy2d::Animation::Animation(const Images& frames)
|
||||||
: interval_(1)
|
: interval_(1)
|
||||||
{
|
{
|
||||||
this->Add(frames);
|
this->Add(frames);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Animation::Animation(float interval)
|
easy2d::Animation::Animation(float interval)
|
||||||
: interval_(interval)
|
: interval_(interval)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Animation::Animation(float interval, const Images& frames)
|
easy2d::Animation::Animation(float interval, const Images& frames)
|
||||||
: interval_(interval)
|
: interval_(interval)
|
||||||
{
|
{
|
||||||
this->Add(frames);
|
this->Add(frames);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Animation::~Animation()
|
easy2d::Animation::~Animation()
|
||||||
{
|
{
|
||||||
for (auto frame : frames_)
|
for (auto frame : frames_)
|
||||||
{
|
{
|
||||||
|
|
@ -50,12 +50,12 @@ e2d::Animation::~Animation()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Animation::SetInterval(float interval)
|
void easy2d::Animation::SetInterval(float interval)
|
||||||
{
|
{
|
||||||
interval_ = std::max(interval, 0.f);
|
interval_ = std::max(interval, 0.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Animation::Add(Image * frame)
|
void easy2d::Animation::Add(Image * frame)
|
||||||
{
|
{
|
||||||
WARN_IF(frame == nullptr, "Animation::Add failed, frame Is nullptr.");
|
WARN_IF(frame == nullptr, "Animation::Add failed, frame Is nullptr.");
|
||||||
if (frame)
|
if (frame)
|
||||||
|
|
@ -65,7 +65,7 @@ void e2d::Animation::Add(Image * frame)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Animation::Add(const Images& frames)
|
void easy2d::Animation::Add(const Images& frames)
|
||||||
{
|
{
|
||||||
for (const auto &image : frames)
|
for (const auto &image : frames)
|
||||||
{
|
{
|
||||||
|
|
@ -73,17 +73,17 @@ void e2d::Animation::Add(const Images& frames)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Animation::GetInterval() const
|
float easy2d::Animation::GetInterval() const
|
||||||
{
|
{
|
||||||
return interval_;
|
return interval_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const e2d::Animation::Images& e2d::Animation::GetFrames() const
|
const easy2d::Animation::Images& easy2d::Animation::GetFrames() const
|
||||||
{
|
{
|
||||||
return frames_;
|
return frames_;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Animation * e2d::Animation::Clone() const
|
easy2d::Animation * easy2d::Animation::Clone() const
|
||||||
{
|
{
|
||||||
auto animation = new Animation(interval_);
|
auto animation = new Animation(interval_);
|
||||||
if (animation)
|
if (animation)
|
||||||
|
|
@ -96,7 +96,7 @@ e2d::Animation * e2d::Animation::Clone() const
|
||||||
return animation;
|
return animation;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Animation * e2d::Animation::Reverse() const
|
easy2d::Animation * easy2d::Animation::Reverse() const
|
||||||
{
|
{
|
||||||
auto& oldFrames = this->GetFrames();
|
auto& oldFrames = this->GetFrames();
|
||||||
Images frames(oldFrames.size());
|
Images frames(oldFrames.size());
|
||||||
|
|
|
||||||
|
|
@ -20,26 +20,26 @@
|
||||||
|
|
||||||
#include "..\e2daction.h"
|
#include "..\e2daction.h"
|
||||||
|
|
||||||
e2d::Callback::Callback(const Function& func) :
|
easy2d::Callback::Callback(const Function& func) :
|
||||||
callback_(func)
|
callback_(func)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Callback * e2d::Callback::Clone() const
|
easy2d::Callback * easy2d::Callback::Clone() const
|
||||||
{
|
{
|
||||||
return new Callback(callback_);
|
return new Callback(callback_);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Callback * e2d::Callback::Reverse() const
|
easy2d::Callback * easy2d::Callback::Reverse() const
|
||||||
{
|
{
|
||||||
return new Callback(callback_);
|
return new Callback(callback_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Callback::Init()
|
void easy2d::Callback::Init()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Callback::Update()
|
void easy2d::Callback::Update()
|
||||||
{
|
{
|
||||||
callback_();
|
callback_();
|
||||||
this->Stop();
|
this->Stop();
|
||||||
|
|
|
||||||
|
|
@ -20,34 +20,34 @@
|
||||||
|
|
||||||
#include "..\e2daction.h"
|
#include "..\e2daction.h"
|
||||||
|
|
||||||
e2d::Delay::Delay(float duration)
|
easy2d::Delay::Delay(float duration)
|
||||||
: delta_(0)
|
: delta_(0)
|
||||||
, delay_(std::max(duration, 0.f))
|
, delay_(std::max(duration, 0.f))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Delay * e2d::Delay::Clone() const
|
easy2d::Delay * easy2d::Delay::Clone() const
|
||||||
{
|
{
|
||||||
return new Delay(delay_);
|
return new Delay(delay_);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Delay * e2d::Delay::Reverse() const
|
easy2d::Delay * easy2d::Delay::Reverse() const
|
||||||
{
|
{
|
||||||
return new Delay(delay_);
|
return new Delay(delay_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Delay::Reset()
|
void easy2d::Delay::Reset()
|
||||||
{
|
{
|
||||||
Action::Reset();
|
Action::Reset();
|
||||||
delta_ = 0;
|
delta_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Delay::Init()
|
void easy2d::Delay::Init()
|
||||||
{
|
{
|
||||||
Action::Init();
|
Action::Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Delay::Update()
|
void easy2d::Delay::Update()
|
||||||
{
|
{
|
||||||
Action::Update();
|
Action::Update();
|
||||||
|
|
||||||
|
|
@ -59,7 +59,7 @@ void e2d::Delay::Update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Delay::ResetTime()
|
void easy2d::Delay::ResetTime()
|
||||||
{
|
{
|
||||||
Action::ResetTime();
|
Action::ResetTime();
|
||||||
started_ = Time::Now() - Duration(delta_);
|
started_ = Time::Now() - Duration(delta_);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#include "..\e2daction.h"
|
#include "..\e2daction.h"
|
||||||
|
|
||||||
e2d::FadeIn::FadeIn(float duration)
|
easy2d::FadeIn::FadeIn(float duration)
|
||||||
: OpacityTo(duration, 1)
|
: OpacityTo(duration, 1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#include "..\e2daction.h"
|
#include "..\e2daction.h"
|
||||||
|
|
||||||
e2d::FadeOut::FadeOut(float duration)
|
easy2d::FadeOut::FadeOut(float duration)
|
||||||
: OpacityTo(duration, 0)
|
: OpacityTo(duration, 0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,24 +20,24 @@
|
||||||
|
|
||||||
#include "..\e2daction.h"
|
#include "..\e2daction.h"
|
||||||
|
|
||||||
e2d::FiniteTimeAction::FiniteTimeAction(float duration)
|
easy2d::FiniteTimeAction::FiniteTimeAction(float duration)
|
||||||
: delta_(0)
|
: delta_(0)
|
||||||
, duration_(std::max(duration, 0.f))
|
, duration_(std::max(duration, 0.f))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::FiniteTimeAction::Reset()
|
void easy2d::FiniteTimeAction::Reset()
|
||||||
{
|
{
|
||||||
Action::Reset();
|
Action::Reset();
|
||||||
delta_ = 0;
|
delta_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::FiniteTimeAction::Init()
|
void easy2d::FiniteTimeAction::Init()
|
||||||
{
|
{
|
||||||
Action::Init();
|
Action::Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::FiniteTimeAction::Update()
|
void easy2d::FiniteTimeAction::Update()
|
||||||
{
|
{
|
||||||
Action::Update();
|
Action::Update();
|
||||||
|
|
||||||
|
|
@ -57,7 +57,7 @@ void e2d::FiniteTimeAction::Update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::FiniteTimeAction::ResetTime()
|
void easy2d::FiniteTimeAction::ResetTime()
|
||||||
{
|
{
|
||||||
Action::ResetTime();
|
Action::ResetTime();
|
||||||
started_ = Time::Now() - Duration(delta_ * duration_);
|
started_ = Time::Now() - Duration(delta_ * duration_);
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
#include "..\e2daction.h"
|
#include "..\e2daction.h"
|
||||||
#include "..\e2dobject.h"
|
#include "..\e2dobject.h"
|
||||||
|
|
||||||
e2d::JumpBy::JumpBy(float duration, const Point & vec, float height, int jumps)
|
easy2d::JumpBy::JumpBy(float duration, const Point & vec, float height, int jumps)
|
||||||
: FiniteTimeAction(duration)
|
: FiniteTimeAction(duration)
|
||||||
, delta_pos_(vec)
|
, delta_pos_(vec)
|
||||||
, height_(height)
|
, height_(height)
|
||||||
|
|
@ -29,17 +29,17 @@ e2d::JumpBy::JumpBy(float duration, const Point & vec, float height, int jumps)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::JumpBy * e2d::JumpBy::Clone() const
|
easy2d::JumpBy * easy2d::JumpBy::Clone() const
|
||||||
{
|
{
|
||||||
return new JumpBy(duration_, delta_pos_, height_, jumps_);
|
return new JumpBy(duration_, delta_pos_, height_, jumps_);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::JumpBy * e2d::JumpBy::Reverse() const
|
easy2d::JumpBy * easy2d::JumpBy::Reverse() const
|
||||||
{
|
{
|
||||||
return new JumpBy(duration_, -delta_pos_, height_, jumps_);
|
return new JumpBy(duration_, -delta_pos_, height_, jumps_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::JumpBy::Init()
|
void easy2d::JumpBy::Init()
|
||||||
{
|
{
|
||||||
FiniteTimeAction::Init();
|
FiniteTimeAction::Init();
|
||||||
|
|
||||||
|
|
@ -49,7 +49,7 @@ void e2d::JumpBy::Init()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::JumpBy::Update()
|
void easy2d::JumpBy::Update()
|
||||||
{
|
{
|
||||||
FiniteTimeAction::Update();
|
FiniteTimeAction::Update();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,18 +21,18 @@
|
||||||
#include "..\e2daction.h"
|
#include "..\e2daction.h"
|
||||||
#include "..\e2dobject.h"
|
#include "..\e2dobject.h"
|
||||||
|
|
||||||
e2d::JumpTo::JumpTo(float duration, const Point & pos, float height, int jumps)
|
easy2d::JumpTo::JumpTo(float duration, const Point & pos, float height, int jumps)
|
||||||
: JumpBy(duration, Point(), height, jumps)
|
: JumpBy(duration, Point(), height, jumps)
|
||||||
, end_pos_(pos)
|
, end_pos_(pos)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::JumpTo * e2d::JumpTo::Clone() const
|
easy2d::JumpTo * easy2d::JumpTo::Clone() const
|
||||||
{
|
{
|
||||||
return new JumpTo(duration_, end_pos_, height_, jumps_);
|
return new JumpTo(duration_, end_pos_, height_, jumps_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::JumpTo::Init()
|
void easy2d::JumpTo::Init()
|
||||||
{
|
{
|
||||||
JumpBy::Init();
|
JumpBy::Init();
|
||||||
delta_pos_ = end_pos_ - start_pos_;
|
delta_pos_ = end_pos_ - start_pos_;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#include "..\e2daction.h"
|
#include "..\e2daction.h"
|
||||||
|
|
||||||
e2d::Loop::Loop(Action * action, int times /* = -1 */)
|
easy2d::Loop::Loop(Action * action, int times /* = -1 */)
|
||||||
: action_(action)
|
: action_(action)
|
||||||
, times_(0)
|
, times_(0)
|
||||||
, total_times_(times)
|
, total_times_(times)
|
||||||
|
|
@ -34,12 +34,12 @@ e2d::Loop::Loop(Action * action, int times /* = -1 */)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Loop::~Loop()
|
easy2d::Loop::~Loop()
|
||||||
{
|
{
|
||||||
SafeRelease(action_);
|
SafeRelease(action_);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Loop * e2d::Loop::Clone() const
|
easy2d::Loop * easy2d::Loop::Clone() const
|
||||||
{
|
{
|
||||||
if (action_)
|
if (action_)
|
||||||
{
|
{
|
||||||
|
|
@ -51,7 +51,7 @@ e2d::Loop * e2d::Loop::Clone() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Loop * e2d::Loop::Reverse() const
|
easy2d::Loop * easy2d::Loop::Reverse() const
|
||||||
{
|
{
|
||||||
if (action_)
|
if (action_)
|
||||||
{
|
{
|
||||||
|
|
@ -63,7 +63,7 @@ e2d::Loop * e2d::Loop::Reverse() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Loop::Init()
|
void easy2d::Loop::Init()
|
||||||
{
|
{
|
||||||
Action::Init();
|
Action::Init();
|
||||||
|
|
||||||
|
|
@ -74,7 +74,7 @@ void e2d::Loop::Init()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Loop::Update()
|
void easy2d::Loop::Update()
|
||||||
{
|
{
|
||||||
Action::Update();
|
Action::Update();
|
||||||
|
|
||||||
|
|
@ -102,7 +102,7 @@ void e2d::Loop::Update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Loop::Reset()
|
void easy2d::Loop::Reset()
|
||||||
{
|
{
|
||||||
Action::Reset();
|
Action::Reset();
|
||||||
|
|
||||||
|
|
@ -110,7 +110,7 @@ void e2d::Loop::Reset()
|
||||||
times_ = 0;
|
times_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Loop::ResetTime()
|
void easy2d::Loop::ResetTime()
|
||||||
{
|
{
|
||||||
if (action_) action_->ResetTime();
|
if (action_) action_->ResetTime();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,13 +22,13 @@
|
||||||
#include "..\e2dobject.h"
|
#include "..\e2dobject.h"
|
||||||
|
|
||||||
|
|
||||||
e2d::MoveBy::MoveBy(float duration, Point vector)
|
easy2d::MoveBy::MoveBy(float duration, Point vector)
|
||||||
: FiniteTimeAction(duration)
|
: FiniteTimeAction(duration)
|
||||||
{
|
{
|
||||||
delta_pos_ = vector;
|
delta_pos_ = vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::MoveBy::Init()
|
void easy2d::MoveBy::Init()
|
||||||
{
|
{
|
||||||
FiniteTimeAction::Init();
|
FiniteTimeAction::Init();
|
||||||
|
|
||||||
|
|
@ -38,7 +38,7 @@ void e2d::MoveBy::Init()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::MoveBy::Update()
|
void easy2d::MoveBy::Update()
|
||||||
{
|
{
|
||||||
FiniteTimeAction::Update();
|
FiniteTimeAction::Update();
|
||||||
|
|
||||||
|
|
@ -55,12 +55,12 @@ void e2d::MoveBy::Update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::MoveBy * e2d::MoveBy::Clone() const
|
easy2d::MoveBy * easy2d::MoveBy::Clone() const
|
||||||
{
|
{
|
||||||
return new MoveBy(duration_, delta_pos_);
|
return new MoveBy(duration_, delta_pos_);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::MoveBy * e2d::MoveBy::Reverse() const
|
easy2d::MoveBy * easy2d::MoveBy::Reverse() const
|
||||||
{
|
{
|
||||||
return new MoveBy(duration_, -delta_pos_);
|
return new MoveBy(duration_, -delta_pos_);
|
||||||
}
|
}
|
||||||
|
|
@ -21,18 +21,18 @@
|
||||||
#include "..\e2daction.h"
|
#include "..\e2daction.h"
|
||||||
#include "..\e2dobject.h"
|
#include "..\e2dobject.h"
|
||||||
|
|
||||||
e2d::MoveTo::MoveTo(float duration, Point pos)
|
easy2d::MoveTo::MoveTo(float duration, Point pos)
|
||||||
: MoveBy(duration, Point())
|
: MoveBy(duration, Point())
|
||||||
{
|
{
|
||||||
end_pos_ = pos;
|
end_pos_ = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::MoveTo * e2d::MoveTo::Clone() const
|
easy2d::MoveTo * easy2d::MoveTo::Clone() const
|
||||||
{
|
{
|
||||||
return new MoveTo(duration_, end_pos_);
|
return new MoveTo(duration_, end_pos_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::MoveTo::Init()
|
void easy2d::MoveTo::Init()
|
||||||
{
|
{
|
||||||
MoveBy::Init();
|
MoveBy::Init();
|
||||||
delta_pos_ = end_pos_ - start_pos_;
|
delta_pos_ = end_pos_ - start_pos_;
|
||||||
|
|
|
||||||
|
|
@ -22,13 +22,13 @@
|
||||||
#include "..\e2dobject.h"
|
#include "..\e2dobject.h"
|
||||||
|
|
||||||
|
|
||||||
e2d::OpacityBy::OpacityBy(float duration, float opacity)
|
easy2d::OpacityBy::OpacityBy(float duration, float opacity)
|
||||||
: FiniteTimeAction(duration)
|
: FiniteTimeAction(duration)
|
||||||
{
|
{
|
||||||
delta_val_ = opacity;
|
delta_val_ = opacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::OpacityBy::Init()
|
void easy2d::OpacityBy::Init()
|
||||||
{
|
{
|
||||||
FiniteTimeAction::Init();
|
FiniteTimeAction::Init();
|
||||||
|
|
||||||
|
|
@ -38,7 +38,7 @@ void e2d::OpacityBy::Init()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::OpacityBy::Update()
|
void easy2d::OpacityBy::Update()
|
||||||
{
|
{
|
||||||
FiniteTimeAction::Update();
|
FiniteTimeAction::Update();
|
||||||
|
|
||||||
|
|
@ -48,12 +48,12 @@ void e2d::OpacityBy::Update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::OpacityBy * e2d::OpacityBy::Clone() const
|
easy2d::OpacityBy * easy2d::OpacityBy::Clone() const
|
||||||
{
|
{
|
||||||
return new OpacityBy(duration_, delta_val_);
|
return new OpacityBy(duration_, delta_val_);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::OpacityBy * e2d::OpacityBy::Reverse() const
|
easy2d::OpacityBy * easy2d::OpacityBy::Reverse() const
|
||||||
{
|
{
|
||||||
return new OpacityBy(duration_, -delta_val_);
|
return new OpacityBy(duration_, -delta_val_);
|
||||||
}
|
}
|
||||||
|
|
@ -22,18 +22,18 @@
|
||||||
#include "..\e2dobject.h"
|
#include "..\e2dobject.h"
|
||||||
|
|
||||||
|
|
||||||
e2d::OpacityTo::OpacityTo(float duration, float opacity)
|
easy2d::OpacityTo::OpacityTo(float duration, float opacity)
|
||||||
: OpacityBy(duration, 0)
|
: OpacityBy(duration, 0)
|
||||||
{
|
{
|
||||||
end_val_ = opacity;
|
end_val_ = opacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::OpacityTo * e2d::OpacityTo::Clone() const
|
easy2d::OpacityTo * easy2d::OpacityTo::Clone() const
|
||||||
{
|
{
|
||||||
return new OpacityTo(duration_, end_val_);
|
return new OpacityTo(duration_, end_val_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::OpacityTo::Init()
|
void easy2d::OpacityTo::Init()
|
||||||
{
|
{
|
||||||
OpacityBy::Init();
|
OpacityBy::Init();
|
||||||
delta_val_ = end_val_ - start_val_;
|
delta_val_ = end_val_ - start_val_;
|
||||||
|
|
|
||||||
|
|
@ -22,13 +22,13 @@
|
||||||
#include "..\e2dobject.h"
|
#include "..\e2dobject.h"
|
||||||
|
|
||||||
|
|
||||||
e2d::RotateBy::RotateBy(float duration, float rotation)
|
easy2d::RotateBy::RotateBy(float duration, float rotation)
|
||||||
: FiniteTimeAction(duration)
|
: FiniteTimeAction(duration)
|
||||||
{
|
{
|
||||||
delta_val_ = rotation;
|
delta_val_ = rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::RotateBy::Init()
|
void easy2d::RotateBy::Init()
|
||||||
{
|
{
|
||||||
FiniteTimeAction::Init();
|
FiniteTimeAction::Init();
|
||||||
|
|
||||||
|
|
@ -38,7 +38,7 @@ void e2d::RotateBy::Init()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::RotateBy::Update()
|
void easy2d::RotateBy::Update()
|
||||||
{
|
{
|
||||||
FiniteTimeAction::Update();
|
FiniteTimeAction::Update();
|
||||||
|
|
||||||
|
|
@ -48,12 +48,12 @@ void e2d::RotateBy::Update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::RotateBy * e2d::RotateBy::Clone() const
|
easy2d::RotateBy * easy2d::RotateBy::Clone() const
|
||||||
{
|
{
|
||||||
return new RotateBy(duration_, delta_val_);
|
return new RotateBy(duration_, delta_val_);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::RotateBy * e2d::RotateBy::Reverse() const
|
easy2d::RotateBy * easy2d::RotateBy::Reverse() const
|
||||||
{
|
{
|
||||||
return new RotateBy(duration_, -delta_val_);
|
return new RotateBy(duration_, -delta_val_);
|
||||||
}
|
}
|
||||||
|
|
@ -22,18 +22,18 @@
|
||||||
#include "..\e2dobject.h"
|
#include "..\e2dobject.h"
|
||||||
|
|
||||||
|
|
||||||
e2d::RotateTo::RotateTo(float duration, float rotation)
|
easy2d::RotateTo::RotateTo(float duration, float rotation)
|
||||||
: RotateBy(duration, 0)
|
: RotateBy(duration, 0)
|
||||||
{
|
{
|
||||||
end_val_ = rotation;
|
end_val_ = rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::RotateTo * e2d::RotateTo::Clone() const
|
easy2d::RotateTo * easy2d::RotateTo::Clone() const
|
||||||
{
|
{
|
||||||
return new RotateTo(duration_, end_val_);
|
return new RotateTo(duration_, end_val_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::RotateTo::Init()
|
void easy2d::RotateTo::Init()
|
||||||
{
|
{
|
||||||
RotateBy::Init();
|
RotateBy::Init();
|
||||||
delta_val_ = end_val_ - start_val_;
|
delta_val_ = end_val_ - start_val_;
|
||||||
|
|
|
||||||
|
|
@ -22,21 +22,21 @@
|
||||||
#include "..\e2dobject.h"
|
#include "..\e2dobject.h"
|
||||||
|
|
||||||
|
|
||||||
e2d::ScaleBy::ScaleBy(float duration, float scale)
|
easy2d::ScaleBy::ScaleBy(float duration, float scale)
|
||||||
: FiniteTimeAction(duration)
|
: FiniteTimeAction(duration)
|
||||||
{
|
{
|
||||||
delta_x_ = scale;
|
delta_x_ = scale;
|
||||||
delta_y_ = scale;
|
delta_y_ = scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::ScaleBy::ScaleBy(float duration, float scale_x, float scale_y)
|
easy2d::ScaleBy::ScaleBy(float duration, float scale_x, float scale_y)
|
||||||
: FiniteTimeAction(duration)
|
: FiniteTimeAction(duration)
|
||||||
{
|
{
|
||||||
delta_x_ = scale_x;
|
delta_x_ = scale_x;
|
||||||
delta_y_ = scale_y;
|
delta_y_ = scale_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::ScaleBy::Init()
|
void easy2d::ScaleBy::Init()
|
||||||
{
|
{
|
||||||
FiniteTimeAction::Init();
|
FiniteTimeAction::Init();
|
||||||
|
|
||||||
|
|
@ -47,7 +47,7 @@ void e2d::ScaleBy::Init()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::ScaleBy::Update()
|
void easy2d::ScaleBy::Update()
|
||||||
{
|
{
|
||||||
FiniteTimeAction::Update();
|
FiniteTimeAction::Update();
|
||||||
|
|
||||||
|
|
@ -57,12 +57,12 @@ void e2d::ScaleBy::Update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::ScaleBy * e2d::ScaleBy::Clone() const
|
easy2d::ScaleBy * easy2d::ScaleBy::Clone() const
|
||||||
{
|
{
|
||||||
return new ScaleBy(duration_, delta_x_, delta_y_);
|
return new ScaleBy(duration_, delta_x_, delta_y_);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::ScaleBy * e2d::ScaleBy::Reverse() const
|
easy2d::ScaleBy * easy2d::ScaleBy::Reverse() const
|
||||||
{
|
{
|
||||||
return new ScaleBy(duration_, -delta_x_, -delta_y_);
|
return new ScaleBy(duration_, -delta_x_, -delta_y_);
|
||||||
}
|
}
|
||||||
|
|
@ -21,26 +21,26 @@
|
||||||
#include "..\e2daction.h"
|
#include "..\e2daction.h"
|
||||||
#include "..\e2dobject.h"
|
#include "..\e2dobject.h"
|
||||||
|
|
||||||
e2d::ScaleTo::ScaleTo(float duration, float scale)
|
easy2d::ScaleTo::ScaleTo(float duration, float scale)
|
||||||
: ScaleBy(duration, 0, 0)
|
: ScaleBy(duration, 0, 0)
|
||||||
{
|
{
|
||||||
end_scale_x_ = scale;
|
end_scale_x_ = scale;
|
||||||
end_scale_y_ = scale;
|
end_scale_y_ = scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::ScaleTo::ScaleTo(float duration, float scale_x, float scale_y)
|
easy2d::ScaleTo::ScaleTo(float duration, float scale_x, float scale_y)
|
||||||
: ScaleBy(duration, 0, 0)
|
: ScaleBy(duration, 0, 0)
|
||||||
{
|
{
|
||||||
end_scale_x_ = scale_x;
|
end_scale_x_ = scale_x;
|
||||||
end_scale_y_ = scale_y;
|
end_scale_y_ = scale_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::ScaleTo * e2d::ScaleTo::Clone() const
|
easy2d::ScaleTo * easy2d::ScaleTo::Clone() const
|
||||||
{
|
{
|
||||||
return new ScaleTo(duration_, end_scale_x_, end_scale_y_);
|
return new ScaleTo(duration_, end_scale_x_, end_scale_y_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::ScaleTo::Init()
|
void easy2d::ScaleTo::Init()
|
||||||
{
|
{
|
||||||
ScaleBy::Init();
|
ScaleBy::Init();
|
||||||
delta_x_ = end_scale_x_ - start_scale_x_;
|
delta_x_ = end_scale_x_ - start_scale_x_;
|
||||||
|
|
|
||||||
|
|
@ -20,18 +20,18 @@
|
||||||
|
|
||||||
#include "..\e2daction.h"
|
#include "..\e2daction.h"
|
||||||
|
|
||||||
e2d::Sequence::Sequence()
|
easy2d::Sequence::Sequence()
|
||||||
: action_index_(0)
|
: action_index_(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Sequence::Sequence(const Actions& actions)
|
easy2d::Sequence::Sequence(const Actions& actions)
|
||||||
: action_index_(0)
|
: action_index_(0)
|
||||||
{
|
{
|
||||||
this->Add(actions);
|
this->Add(actions);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Sequence::~Sequence()
|
easy2d::Sequence::~Sequence()
|
||||||
{
|
{
|
||||||
for (auto action : actions_)
|
for (auto action : actions_)
|
||||||
{
|
{
|
||||||
|
|
@ -39,7 +39,7 @@ e2d::Sequence::~Sequence()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Sequence::Init()
|
void easy2d::Sequence::Init()
|
||||||
{
|
{
|
||||||
Action::Init();
|
Action::Init();
|
||||||
// ½«ËùÓж¯×÷ÓëÄ¿±ê°ó¶¨
|
// ½«ËùÓж¯×÷ÓëÄ¿±ê°ó¶¨
|
||||||
|
|
@ -54,7 +54,7 @@ void e2d::Sequence::Init()
|
||||||
actions_[0]->Init();
|
actions_[0]->Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Sequence::Update()
|
void easy2d::Sequence::Update()
|
||||||
{
|
{
|
||||||
Action::Update();
|
Action::Update();
|
||||||
|
|
||||||
|
|
@ -75,7 +75,7 @@ void e2d::Sequence::Update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Sequence::Reset()
|
void easy2d::Sequence::Reset()
|
||||||
{
|
{
|
||||||
Action::Reset();
|
Action::Reset();
|
||||||
for (const auto& action : actions_)
|
for (const auto& action : actions_)
|
||||||
|
|
@ -85,7 +85,7 @@ void e2d::Sequence::Reset()
|
||||||
action_index_ = 0;
|
action_index_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Sequence::ResetTime()
|
void easy2d::Sequence::ResetTime()
|
||||||
{
|
{
|
||||||
for (const auto& action : actions_)
|
for (const auto& action : actions_)
|
||||||
{
|
{
|
||||||
|
|
@ -93,7 +93,7 @@ void e2d::Sequence::ResetTime()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Sequence::Add(Action * action)
|
void easy2d::Sequence::Add(Action * action)
|
||||||
{
|
{
|
||||||
if (action)
|
if (action)
|
||||||
{
|
{
|
||||||
|
|
@ -102,7 +102,7 @@ void e2d::Sequence::Add(Action * action)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Sequence::Add(const Actions& actions)
|
void easy2d::Sequence::Add(const Actions& actions)
|
||||||
{
|
{
|
||||||
for (const auto &action : actions)
|
for (const auto &action : actions)
|
||||||
{
|
{
|
||||||
|
|
@ -110,7 +110,7 @@ void e2d::Sequence::Add(const Actions& actions)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Sequence * e2d::Sequence::Clone() const
|
easy2d::Sequence * easy2d::Sequence::Clone() const
|
||||||
{
|
{
|
||||||
auto sequence = new Sequence();
|
auto sequence = new Sequence();
|
||||||
for (const auto& action : actions_)
|
for (const auto& action : actions_)
|
||||||
|
|
@ -123,7 +123,7 @@ e2d::Sequence * e2d::Sequence::Clone() const
|
||||||
return sequence;
|
return sequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Sequence * e2d::Sequence::Reverse() const
|
easy2d::Sequence * easy2d::Sequence::Reverse() const
|
||||||
{
|
{
|
||||||
auto sequence = new Sequence();
|
auto sequence = new Sequence();
|
||||||
if (sequence && !actions_.empty())
|
if (sequence && !actions_.empty())
|
||||||
|
|
|
||||||
|
|
@ -20,16 +20,16 @@
|
||||||
|
|
||||||
#include "..\e2daction.h"
|
#include "..\e2daction.h"
|
||||||
|
|
||||||
e2d::Spawn::Spawn()
|
easy2d::Spawn::Spawn()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Spawn::Spawn(const Actions& actions)
|
easy2d::Spawn::Spawn(const Actions& actions)
|
||||||
{
|
{
|
||||||
this->Add(actions);
|
this->Add(actions);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Spawn::~Spawn()
|
easy2d::Spawn::~Spawn()
|
||||||
{
|
{
|
||||||
for (auto action : actions_)
|
for (auto action : actions_)
|
||||||
{
|
{
|
||||||
|
|
@ -37,7 +37,7 @@ e2d::Spawn::~Spawn()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Spawn::Init()
|
void easy2d::Spawn::Init()
|
||||||
{
|
{
|
||||||
Action::Init();
|
Action::Init();
|
||||||
|
|
||||||
|
|
@ -51,7 +51,7 @@ void e2d::Spawn::Init()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Spawn::Update()
|
void easy2d::Spawn::Update()
|
||||||
{
|
{
|
||||||
Action::Update();
|
Action::Update();
|
||||||
|
|
||||||
|
|
@ -74,7 +74,7 @@ void e2d::Spawn::Update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Spawn::Reset()
|
void easy2d::Spawn::Reset()
|
||||||
{
|
{
|
||||||
Action::Reset();
|
Action::Reset();
|
||||||
for (const auto& action : actions_)
|
for (const auto& action : actions_)
|
||||||
|
|
@ -83,7 +83,7 @@ void e2d::Spawn::Reset()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Spawn::ResetTime()
|
void easy2d::Spawn::ResetTime()
|
||||||
{
|
{
|
||||||
for (const auto& action : actions_)
|
for (const auto& action : actions_)
|
||||||
{
|
{
|
||||||
|
|
@ -91,7 +91,7 @@ void e2d::Spawn::ResetTime()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Spawn::Add(Action * action)
|
void easy2d::Spawn::Add(Action * action)
|
||||||
{
|
{
|
||||||
if (action)
|
if (action)
|
||||||
{
|
{
|
||||||
|
|
@ -100,7 +100,7 @@ void e2d::Spawn::Add(Action * action)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Spawn::Add(const Actions& actions)
|
void easy2d::Spawn::Add(const Actions& actions)
|
||||||
{
|
{
|
||||||
for (const auto &action : actions)
|
for (const auto &action : actions)
|
||||||
{
|
{
|
||||||
|
|
@ -108,7 +108,7 @@ void e2d::Spawn::Add(const Actions& actions)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Spawn * e2d::Spawn::Clone() const
|
easy2d::Spawn * easy2d::Spawn::Clone() const
|
||||||
{
|
{
|
||||||
auto spawn = new Spawn();
|
auto spawn = new Spawn();
|
||||||
for (const auto& action : actions_)
|
for (const auto& action : actions_)
|
||||||
|
|
@ -121,7 +121,7 @@ e2d::Spawn * e2d::Spawn::Clone() const
|
||||||
return spawn;
|
return spawn;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Spawn * e2d::Spawn::Reverse() const
|
easy2d::Spawn * easy2d::Spawn::Reverse() const
|
||||||
{
|
{
|
||||||
auto spawn = new Spawn();
|
auto spawn = new Spawn();
|
||||||
if (spawn && !actions_.empty())
|
if (spawn && !actions_.empty())
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
} \
|
} \
|
||||||
|
|
||||||
|
|
||||||
e2d::Button::Button()
|
easy2d::Button::Button()
|
||||||
: callback_(nullptr)
|
: callback_(nullptr)
|
||||||
, status_(Status::Normal)
|
, status_(Status::Normal)
|
||||||
, enabled_(true)
|
, enabled_(true)
|
||||||
|
|
@ -49,7 +49,7 @@ e2d::Button::Button()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Button::Button(Node * normal, const Function& func)
|
easy2d::Button::Button(Node * normal, const Function& func)
|
||||||
: callback_(nullptr)
|
: callback_(nullptr)
|
||||||
, status_(Status::Normal)
|
, status_(Status::Normal)
|
||||||
, enabled_(true)
|
, enabled_(true)
|
||||||
|
|
@ -63,7 +63,7 @@ e2d::Button::Button(Node * normal, const Function& func)
|
||||||
this->SetCallbackOnClick(func);
|
this->SetCallbackOnClick(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Button::Button(Node * normal, Node * selected, const Function& func)
|
easy2d::Button::Button(Node * normal, Node * selected, const Function& func)
|
||||||
: callback_(nullptr)
|
: callback_(nullptr)
|
||||||
, status_(Status::Normal)
|
, status_(Status::Normal)
|
||||||
, enabled_(true)
|
, enabled_(true)
|
||||||
|
|
@ -78,7 +78,7 @@ e2d::Button::Button(Node * normal, Node * selected, const Function& func)
|
||||||
this->SetCallbackOnClick(func);
|
this->SetCallbackOnClick(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, const Function& func)
|
easy2d::Button::Button(Node * normal, Node * mouseover, Node * selected, const Function& func)
|
||||||
: callback_(nullptr)
|
: callback_(nullptr)
|
||||||
, status_(Status::Normal)
|
, status_(Status::Normal)
|
||||||
, enabled_(true)
|
, enabled_(true)
|
||||||
|
|
@ -94,7 +94,7 @@ e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, const Func
|
||||||
this->SetCallbackOnClick(func);
|
this->SetCallbackOnClick(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, Node * disabled, const Function& func)
|
easy2d::Button::Button(Node * normal, Node * mouseover, Node * selected, Node * disabled, const Function& func)
|
||||||
: callback_(nullptr)
|
: callback_(nullptr)
|
||||||
, status_(Status::Normal)
|
, status_(Status::Normal)
|
||||||
, enabled_(true)
|
, enabled_(true)
|
||||||
|
|
@ -111,12 +111,12 @@ e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, Node * dis
|
||||||
this->SetCallbackOnClick(func);
|
this->SetCallbackOnClick(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Button::IsEnable() const
|
bool easy2d::Button::IsEnable() const
|
||||||
{
|
{
|
||||||
return enabled_;
|
return enabled_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Button::SetNormal(Node * normal)
|
void easy2d::Button::SetNormal(Node * normal)
|
||||||
{
|
{
|
||||||
SET_BUTTON_NODE(normal_, normal);
|
SET_BUTTON_NODE(normal_, normal);
|
||||||
if (normal)
|
if (normal)
|
||||||
|
|
@ -125,22 +125,22 @@ void e2d::Button::SetNormal(Node * normal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Button::SetMouseOver(Node * mouseover)
|
void easy2d::Button::SetMouseOver(Node * mouseover)
|
||||||
{
|
{
|
||||||
SET_BUTTON_NODE(mouseover_, mouseover);
|
SET_BUTTON_NODE(mouseover_, mouseover);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Button::SetSelected(Node * selected)
|
void easy2d::Button::SetSelected(Node * selected)
|
||||||
{
|
{
|
||||||
SET_BUTTON_NODE(selected_, selected);
|
SET_BUTTON_NODE(selected_, selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Button::SetDisabled(Node * disabled)
|
void easy2d::Button::SetDisabled(Node * disabled)
|
||||||
{
|
{
|
||||||
SET_BUTTON_NODE(disabled_, disabled);
|
SET_BUTTON_NODE(disabled_, disabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Button::SetEnabled(bool enabled)
|
void easy2d::Button::SetEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
if (enabled_ != enabled)
|
if (enabled_ != enabled)
|
||||||
{
|
{
|
||||||
|
|
@ -149,12 +149,12 @@ void e2d::Button::SetEnabled(bool enabled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Button::SetCallbackOnClick(const Function& func)
|
void easy2d::Button::SetCallbackOnClick(const Function& func)
|
||||||
{
|
{
|
||||||
callback_ = func;
|
callback_ = func;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Button::SetPivot(float pivot_x, float pivot_y)
|
void easy2d::Button::SetPivot(float pivot_x, float pivot_y)
|
||||||
{
|
{
|
||||||
Node::SetPivot(pivot_x, pivot_y);
|
Node::SetPivot(pivot_x, pivot_y);
|
||||||
SAFE_SET(normal_, SetPivot, pivot_x, pivot_y);
|
SAFE_SET(normal_, SetPivot, pivot_x, pivot_y);
|
||||||
|
|
@ -163,7 +163,7 @@ void e2d::Button::SetPivot(float pivot_x, float pivot_y)
|
||||||
SAFE_SET(disabled_, SetPivot, pivot_x, pivot_y);
|
SAFE_SET(disabled_, SetPivot, pivot_x, pivot_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Button::Dispatch(const MouseEvent & e, bool handled)
|
bool easy2d::Button::Dispatch(const MouseEvent & e, bool handled)
|
||||||
{
|
{
|
||||||
if (!handled && enabled_ && visible_ && normal_)
|
if (!handled && enabled_ && visible_ && normal_)
|
||||||
{
|
{
|
||||||
|
|
@ -212,7 +212,7 @@ bool e2d::Button::Dispatch(const MouseEvent & e, bool handled)
|
||||||
return Node::Dispatch(e, handled);
|
return Node::Dispatch(e, handled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Button::Visit()
|
void easy2d::Button::Visit()
|
||||||
{
|
{
|
||||||
Node::Visit();
|
Node::Visit();
|
||||||
|
|
||||||
|
|
@ -237,7 +237,7 @@ void e2d::Button::Visit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Button::SetStatus(Status status)
|
void easy2d::Button::SetStatus(Status status)
|
||||||
{
|
{
|
||||||
if (status_ != status)
|
if (status_ != status)
|
||||||
{
|
{
|
||||||
|
|
@ -246,7 +246,7 @@ void e2d::Button::SetStatus(Status status)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Button::UpdateVisible()
|
void easy2d::Button::UpdateVisible()
|
||||||
{
|
{
|
||||||
SAFE_SET(normal_, SetVisible, false);
|
SAFE_SET(normal_, SetVisible, false);
|
||||||
SAFE_SET(mouseover_, SetVisible, false);
|
SAFE_SET(mouseover_, SetVisible, false);
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,12 @@
|
||||||
|
|
||||||
#include "..\e2dcomponent.h"
|
#include "..\e2dcomponent.h"
|
||||||
|
|
||||||
e2d::Menu::Menu()
|
easy2d::Menu::Menu()
|
||||||
: enabled_(true)
|
: enabled_(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Menu::Menu(const std::vector<Button*>& buttons)
|
easy2d::Menu::Menu(const std::vector<Button*>& buttons)
|
||||||
: enabled_(true)
|
: enabled_(true)
|
||||||
{
|
{
|
||||||
for (const auto& button : buttons)
|
for (const auto& button : buttons)
|
||||||
|
|
@ -34,17 +34,17 @@ e2d::Menu::Menu(const std::vector<Button*>& buttons)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Menu::IsEnable() const
|
bool easy2d::Menu::IsEnable() const
|
||||||
{
|
{
|
||||||
return enabled_;
|
return enabled_;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t e2d::Menu::GetButtonCount() const
|
size_t easy2d::Menu::GetButtonCount() const
|
||||||
{
|
{
|
||||||
return buttons_.size();
|
return buttons_.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Menu::SetEnabled(bool enabled)
|
void easy2d::Menu::SetEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
if (enabled_ != enabled)
|
if (enabled_ != enabled)
|
||||||
{
|
{
|
||||||
|
|
@ -57,7 +57,7 @@ void e2d::Menu::SetEnabled(bool enabled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Menu::AddButton(Button * button)
|
void easy2d::Menu::AddButton(Button * button)
|
||||||
{
|
{
|
||||||
if (button)
|
if (button)
|
||||||
{
|
{
|
||||||
|
|
@ -67,7 +67,7 @@ void e2d::Menu::AddButton(Button * button)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Menu::RemoveButton(Button * button)
|
bool easy2d::Menu::RemoveButton(Button * button)
|
||||||
{
|
{
|
||||||
if (buttons_.empty())
|
if (buttons_.empty())
|
||||||
{
|
{
|
||||||
|
|
@ -90,7 +90,7 @@ bool e2d::Menu::RemoveButton(Button * button)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<e2d::Button*>& e2d::Menu::GetAllButtons() const
|
const std::vector<easy2d::Button*>& easy2d::Menu::GetAllButtons() const
|
||||||
{
|
{
|
||||||
return buttons_;
|
return buttons_;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
#include "e2dutil.h"
|
#include "e2dutil.h"
|
||||||
#include "e2dobject.h"
|
#include "e2dobject.h"
|
||||||
|
|
||||||
namespace e2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "e2dobject.h"
|
#include "e2dobject.h"
|
||||||
|
|
||||||
namespace e2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "e2dutil.h"
|
#include "e2dutil.h"
|
||||||
|
|
||||||
namespace e2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "e2dutil.h"
|
#include "e2dutil.h"
|
||||||
|
|
||||||
namespace e2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
#include "e2dtransition.h"
|
#include "e2dtransition.h"
|
||||||
|
|
||||||
|
|
||||||
namespace e2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
|
|
||||||
// 图形设备
|
// 图形设备
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
#include "e2devent.h"
|
#include "e2devent.h"
|
||||||
|
|
||||||
|
|
||||||
namespace e2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
#include "e2dutil.h"
|
#include "e2dutil.h"
|
||||||
#include "e2dimpl.h"
|
#include "e2dimpl.h"
|
||||||
|
|
||||||
namespace e2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
|
|
||||||
// 随机数产生器
|
// 随机数产生器
|
||||||
|
|
@ -33,19 +33,19 @@ namespace e2d
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static inline T Range(T min, T max)
|
static inline T Range(T min, T max)
|
||||||
{
|
{
|
||||||
return e2d::Random::RandomInt(min, max);
|
return easy2d::Random::RandomInt(min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取得范围内的一个浮点数随机数
|
// 取得范围内的一个浮点数随机数
|
||||||
static inline float Range(float min, float max)
|
static inline float Range(float min, float max)
|
||||||
{
|
{
|
||||||
return e2d::Random::RandomReal(min, max);
|
return easy2d::Random::RandomReal(min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取得范围内的一个浮点数随机数
|
// 取得范围内的一个浮点数随机数
|
||||||
static inline double Range(double min, double max)
|
static inline double Range(double min, double max)
|
||||||
{
|
{
|
||||||
return e2d::Random::RandomReal(min, max);
|
return easy2d::Random::RandomReal(min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -79,7 +79,7 @@ namespace e2d
|
||||||
|
|
||||||
// 打开音乐文件
|
// 打开音乐文件
|
||||||
bool Load(
|
bool Load(
|
||||||
const e2d::String& file_path /* 音乐文件路径 */
|
const easy2d::String& file_path /* 音乐文件路径 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 打开音乐资源
|
// 打开音乐资源
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "e2dutil.h"
|
#include "e2dutil.h"
|
||||||
|
|
||||||
namespace e2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "e2dmacros.h"
|
#include "e2dmacros.h"
|
||||||
|
|
||||||
namespace e2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -72,7 +72,7 @@ namespace e2d
|
||||||
Point operator - () const;
|
Point operator - () const;
|
||||||
bool operator== (const Point& other) const;
|
bool operator== (const Point& other) const;
|
||||||
|
|
||||||
E2D_OP_EXPLICIT operator e2d::Size() const;
|
E2D_OP_EXPLICIT operator easy2d::Size() const;
|
||||||
|
|
||||||
// 判断两点间距离
|
// 判断两点间距离
|
||||||
static float Distance(
|
static float Distance(
|
||||||
|
|
@ -108,7 +108,7 @@ namespace e2d
|
||||||
Size operator - () const;
|
Size operator - () const;
|
||||||
bool operator== (const Size& other) const;
|
bool operator== (const Size& other) const;
|
||||||
|
|
||||||
E2D_OP_EXPLICIT operator e2d::Point() const;
|
E2D_OP_EXPLICIT operator easy2d::Point() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,14 +21,14 @@
|
||||||
#include "..\e2devent.h"
|
#include "..\e2devent.h"
|
||||||
|
|
||||||
|
|
||||||
e2d::KeyEvent::KeyEvent(UINT message, WPARAM w_param, LPARAM l_param)
|
easy2d::KeyEvent::KeyEvent(UINT message, WPARAM w_param, LPARAM l_param)
|
||||||
: message_(message)
|
: message_(message)
|
||||||
, w_param_(w_param)
|
, w_param_(w_param)
|
||||||
, l_param_(l_param)
|
, l_param_(l_param)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::KeyCode e2d::KeyEvent::GetCode() const
|
easy2d::KeyCode easy2d::KeyEvent::GetCode() const
|
||||||
{
|
{
|
||||||
switch (w_param_)
|
switch (w_param_)
|
||||||
{
|
{
|
||||||
|
|
@ -89,12 +89,12 @@ e2d::KeyCode e2d::KeyEvent::GetCode() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int e2d::KeyEvent::GetCount() const
|
int easy2d::KeyEvent::GetCount() const
|
||||||
{
|
{
|
||||||
return static_cast<int>((DWORD)l_param_ & 0x0000FFFF);
|
return static_cast<int>((DWORD)l_param_ & 0x0000FFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::KeyEvent::Type e2d::KeyEvent::GetType() const
|
easy2d::KeyEvent::Type easy2d::KeyEvent::GetType() const
|
||||||
{
|
{
|
||||||
return Type(message_);
|
return Type(message_);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,26 +21,26 @@
|
||||||
#include "..\e2devent.h"
|
#include "..\e2devent.h"
|
||||||
#include "..\e2dmodule.h"
|
#include "..\e2dmodule.h"
|
||||||
|
|
||||||
e2d::MouseEvent::MouseEvent(UINT message, WPARAM w_param, LPARAM l_param)
|
easy2d::MouseEvent::MouseEvent(UINT message, WPARAM w_param, LPARAM l_param)
|
||||||
: message_(message)
|
: message_(message)
|
||||||
, w_param_(w_param)
|
, w_param_(w_param)
|
||||||
, l_param_(l_param)
|
, l_param_(l_param)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::MouseEvent::GetX() const
|
float easy2d::MouseEvent::GetX() const
|
||||||
{
|
{
|
||||||
float dpi = Graphics::GetDpi();
|
float dpi = Graphics::GetDpi();
|
||||||
return ((float)(short)LOWORD(l_param_)) * 96.f / dpi;
|
return ((float)(short)LOWORD(l_param_)) * 96.f / dpi;
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::MouseEvent::GetY() const
|
float easy2d::MouseEvent::GetY() const
|
||||||
{
|
{
|
||||||
float dpi = Graphics::GetDpi();
|
float dpi = Graphics::GetDpi();
|
||||||
return ((float)(short)HIWORD(l_param_)) * 96.f / dpi;
|
return ((float)(short)HIWORD(l_param_)) * 96.f / dpi;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Point e2d::MouseEvent::GetPosition() const
|
easy2d::Point easy2d::MouseEvent::GetPosition() const
|
||||||
{
|
{
|
||||||
float dpi = Graphics::GetDpi();
|
float dpi = Graphics::GetDpi();
|
||||||
return Point(
|
return Point(
|
||||||
|
|
@ -49,37 +49,37 @@ e2d::Point e2d::MouseEvent::GetPosition() const
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::MouseEvent::IsShiftDown() const
|
bool easy2d::MouseEvent::IsShiftDown() const
|
||||||
{
|
{
|
||||||
return GET_KEYSTATE_WPARAM(w_param_) == MK_SHIFT;
|
return GET_KEYSTATE_WPARAM(w_param_) == MK_SHIFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::MouseEvent::IsCtrlDown() const
|
bool easy2d::MouseEvent::IsCtrlDown() const
|
||||||
{
|
{
|
||||||
return GET_KEYSTATE_WPARAM(w_param_) == MK_CONTROL;
|
return GET_KEYSTATE_WPARAM(w_param_) == MK_CONTROL;
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::MouseEvent::GetWheelDelta() const
|
float easy2d::MouseEvent::GetWheelDelta() const
|
||||||
{
|
{
|
||||||
return static_cast<float>(GET_WHEEL_DELTA_WPARAM(w_param_));
|
return static_cast<float>(GET_WHEEL_DELTA_WPARAM(w_param_));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::MouseEvent::IsLButtonDown() const
|
bool easy2d::MouseEvent::IsLButtonDown() const
|
||||||
{
|
{
|
||||||
return GET_KEYSTATE_WPARAM(w_param_) == MK_LBUTTON;
|
return GET_KEYSTATE_WPARAM(w_param_) == MK_LBUTTON;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::MouseEvent::IsRButtonDown() const
|
bool easy2d::MouseEvent::IsRButtonDown() const
|
||||||
{
|
{
|
||||||
return GET_KEYSTATE_WPARAM(w_param_) == MK_RBUTTON;
|
return GET_KEYSTATE_WPARAM(w_param_) == MK_RBUTTON;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::MouseEvent::IsMButtonDown() const
|
bool easy2d::MouseEvent::IsMButtonDown() const
|
||||||
{
|
{
|
||||||
return GET_KEYSTATE_WPARAM(w_param_) == MK_MBUTTON;
|
return GET_KEYSTATE_WPARAM(w_param_) == MK_MBUTTON;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::MouseEvent::Type e2d::MouseEvent::GetType() const
|
easy2d::MouseEvent::Type easy2d::MouseEvent::GetType() const
|
||||||
{
|
{
|
||||||
return Type(message_);
|
return Type(message_);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
#include "..\e2dimpl.h"
|
#include "..\e2dimpl.h"
|
||||||
#include "..\e2dmodule.h"
|
#include "..\e2dmodule.h"
|
||||||
|
|
||||||
using namespace e2d;
|
using namespace easy2d;
|
||||||
|
|
||||||
E2DTextRenderer::E2DTextRenderer()
|
E2DTextRenderer::E2DTextRenderer()
|
||||||
: cRefCount_(0)
|
: cRefCount_(0)
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
#include "..\e2dmodule.h"
|
#include "..\e2dmodule.h"
|
||||||
|
|
||||||
|
|
||||||
e2d::Audio::Audio()
|
easy2d::Audio::Audio()
|
||||||
: x_audio2_(nullptr)
|
: x_audio2_(nullptr)
|
||||||
, mastering_voice_(nullptr)
|
, mastering_voice_(nullptr)
|
||||||
{
|
{
|
||||||
|
|
@ -38,7 +38,7 @@ e2d::Audio::Audio()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Audio::~Audio()
|
easy2d::Audio::~Audio()
|
||||||
{
|
{
|
||||||
if (mastering_voice_)
|
if (mastering_voice_)
|
||||||
{
|
{
|
||||||
|
|
@ -51,17 +51,17 @@ e2d::Audio::~Audio()
|
||||||
MFShutdown();
|
MFShutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT e2d::Audio::CreateVoice(IXAudio2SourceVoice ** voice, WAVEFORMATEX * wfx)
|
HRESULT easy2d::Audio::CreateVoice(IXAudio2SourceVoice ** voice, WAVEFORMATEX * wfx)
|
||||||
{
|
{
|
||||||
return x_audio2_->CreateSourceVoice(voice, wfx, 0, XAUDIO2_DEFAULT_FREQ_RATIO);
|
return x_audio2_->CreateSourceVoice(voice, wfx, 0, XAUDIO2_DEFAULT_FREQ_RATIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Audio::Open()
|
void easy2d::Audio::Open()
|
||||||
{
|
{
|
||||||
x_audio2_->StartEngine();
|
x_audio2_->StartEngine();
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Audio::Close()
|
void easy2d::Audio::Close()
|
||||||
{
|
{
|
||||||
x_audio2_->StopEngine();
|
x_audio2_->StopEngine();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,33 +20,33 @@
|
||||||
|
|
||||||
#include "..\e2dmodule.h"
|
#include "..\e2dmodule.h"
|
||||||
|
|
||||||
static e2d::Graphics * graphics_device = nullptr;
|
static easy2d::Graphics * graphics_device = nullptr;
|
||||||
static e2d::Input * input_device = nullptr;
|
static easy2d::Input * input_device = nullptr;
|
||||||
static e2d::Audio * audio_device = nullptr;
|
static easy2d::Audio * audio_device = nullptr;
|
||||||
|
|
||||||
e2d::Graphics * e2d::Device::GetGraphics()
|
easy2d::Graphics * easy2d::Device::GetGraphics()
|
||||||
{
|
{
|
||||||
return graphics_device;
|
return graphics_device;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Input * e2d::Device::GetInput()
|
easy2d::Input * easy2d::Device::GetInput()
|
||||||
{
|
{
|
||||||
return input_device;
|
return input_device;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Audio * e2d::Device::GetAudio()
|
easy2d::Audio * easy2d::Device::GetAudio()
|
||||||
{
|
{
|
||||||
return audio_device;
|
return audio_device;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Device::Init(HWND hwnd)
|
void easy2d::Device::Init(HWND hwnd)
|
||||||
{
|
{
|
||||||
graphics_device = new (std::nothrow) Graphics(hwnd);
|
graphics_device = new (std::nothrow) Graphics(hwnd);
|
||||||
input_device = new (std::nothrow) Input(hwnd);
|
input_device = new (std::nothrow) Input(hwnd);
|
||||||
audio_device = new (std::nothrow) Audio();
|
audio_device = new (std::nothrow) Audio();
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Device::Destroy()
|
void easy2d::Device::Destroy()
|
||||||
{
|
{
|
||||||
if (audio_device)
|
if (audio_device)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -30,14 +30,14 @@
|
||||||
#define REGISTER_CLASS L"Easy2DApp"
|
#define REGISTER_CLASS L"Easy2DApp"
|
||||||
|
|
||||||
|
|
||||||
static e2d::Game * instance = nullptr;
|
static easy2d::Game * instance = nullptr;
|
||||||
|
|
||||||
e2d::Game * e2d::Game::GetInstance()
|
easy2d::Game * easy2d::Game::GetInstance()
|
||||||
{
|
{
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Game::Game()
|
easy2d::Game::Game()
|
||||||
: hwnd_(nullptr)
|
: hwnd_(nullptr)
|
||||||
, quit_(true)
|
, quit_(true)
|
||||||
, curr_scene_(nullptr)
|
, curr_scene_(nullptr)
|
||||||
|
|
@ -58,7 +58,7 @@ e2d::Game::Game()
|
||||||
::CoInitialize(nullptr);
|
::CoInitialize(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Game::~Game()
|
easy2d::Game::~Game()
|
||||||
{
|
{
|
||||||
SafeRelease(transition_);
|
SafeRelease(transition_);
|
||||||
SafeRelease(curr_scene_);
|
SafeRelease(curr_scene_);
|
||||||
|
|
@ -78,7 +78,7 @@ e2d::Game::~Game()
|
||||||
::CoUninitialize();
|
::CoUninitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Game::Run(const Options& options)
|
void easy2d::Game::Run(const Options& options)
|
||||||
{
|
{
|
||||||
title_ = options.title;
|
title_ = options.title;
|
||||||
width_ = options.width;
|
width_ = options.width;
|
||||||
|
|
@ -142,12 +142,12 @@ void e2d::Game::Run(const Options& options)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Game::Quit()
|
void easy2d::Game::Quit()
|
||||||
{
|
{
|
||||||
quit_ = true;
|
quit_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Game::EnterScene(Scene * scene, Transition * transition)
|
void easy2d::Game::EnterScene(Scene * scene, Transition * transition)
|
||||||
{
|
{
|
||||||
if (scene == nullptr)
|
if (scene == nullptr)
|
||||||
{
|
{
|
||||||
|
|
@ -182,17 +182,17 @@ void e2d::Game::EnterScene(Scene * scene, Transition * transition)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Scene * e2d::Game::GetCurrentScene()
|
easy2d::Scene * easy2d::Game::GetCurrentScene()
|
||||||
{
|
{
|
||||||
return curr_scene_;
|
return curr_scene_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Game::IsTransitioning() const
|
bool easy2d::Game::IsTransitioning() const
|
||||||
{
|
{
|
||||||
return transition_ != nullptr;
|
return transition_ != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Game::UpdateScene(float dt)
|
void easy2d::Game::UpdateScene(float dt)
|
||||||
{
|
{
|
||||||
auto update = [&](Scene * scene) -> void
|
auto update = [&](Scene * scene) -> void
|
||||||
{
|
{
|
||||||
|
|
@ -240,7 +240,7 @@ void e2d::Game::UpdateScene(float dt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Game::DrawScene()
|
void easy2d::Game::DrawScene()
|
||||||
{
|
{
|
||||||
auto graphics = Device::GetGraphics();
|
auto graphics = Device::GetGraphics();
|
||||||
graphics->BeginDraw();
|
graphics->BeginDraw();
|
||||||
|
|
@ -274,7 +274,7 @@ void e2d::Game::DrawScene()
|
||||||
graphics->EndDraw();
|
graphics->EndDraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Game::Init()
|
void easy2d::Game::Init()
|
||||||
{
|
{
|
||||||
WNDCLASSEX wcex = { 0 };
|
WNDCLASSEX wcex = { 0 };
|
||||||
wcex.cbSize = sizeof(WNDCLASSEX);
|
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||||
|
|
@ -379,7 +379,7 @@ void e2d::Game::Init()
|
||||||
quit_ = false;
|
quit_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Rect e2d::Game::Locate(int width, int height)
|
easy2d::Rect easy2d::Game::Locate(int width, int height)
|
||||||
{
|
{
|
||||||
int max_width = ::GetSystemMetrics(SM_CXSCREEN);
|
int max_width = ::GetSystemMetrics(SM_CXSCREEN);
|
||||||
int max_height = ::GetSystemMetrics(SM_CYSCREEN);
|
int max_height = ::GetSystemMetrics(SM_CYSCREEN);
|
||||||
|
|
@ -406,36 +406,36 @@ e2d::Rect e2d::Game::Locate(int width, int height)
|
||||||
return std::move(client_rect);
|
return std::move(client_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
int e2d::Game::GetWidth() const
|
int easy2d::Game::GetWidth() const
|
||||||
{
|
{
|
||||||
return width_;
|
return width_;
|
||||||
}
|
}
|
||||||
|
|
||||||
int e2d::Game::GetHeight() const
|
int easy2d::Game::GetHeight() const
|
||||||
{
|
{
|
||||||
return height_;
|
return height_;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Size e2d::Game::GetSize() const
|
easy2d::Size easy2d::Game::GetSize() const
|
||||||
{
|
{
|
||||||
e2d::Size size(
|
easy2d::Size size(
|
||||||
static_cast<float>(width_),
|
static_cast<float>(width_),
|
||||||
static_cast<float>(height_)
|
static_cast<float>(height_)
|
||||||
);
|
);
|
||||||
return std::move(size);
|
return std::move(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
HWND e2d::Game::GetHWnd() const
|
HWND easy2d::Game::GetHWnd() const
|
||||||
{
|
{
|
||||||
return hwnd_;
|
return hwnd_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const e2d::String& e2d::Game::GetTitle() const
|
const easy2d::String& easy2d::Game::GetTitle() const
|
||||||
{
|
{
|
||||||
return title_;
|
return title_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Game::SetSize(int width, int height)
|
void easy2d::Game::SetSize(int width, int height)
|
||||||
{
|
{
|
||||||
if (width_ == width && height_ == height)
|
if (width_ == width && height_ == height)
|
||||||
return;
|
return;
|
||||||
|
|
@ -457,7 +457,7 @@ void e2d::Game::SetSize(int width, int height)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Game::SetTitle(const String& title)
|
void easy2d::Game::SetTitle(const String& title)
|
||||||
{
|
{
|
||||||
title_ = title;
|
title_ = title;
|
||||||
|
|
||||||
|
|
@ -467,7 +467,7 @@ void e2d::Game::SetTitle(const String& title)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Game::SetIcon(int resource_id)
|
void easy2d::Game::SetIcon(int resource_id)
|
||||||
{
|
{
|
||||||
icon_ = resource_id;
|
icon_ = resource_id;
|
||||||
|
|
||||||
|
|
@ -488,7 +488,7 @@ void e2d::Game::SetIcon(int resource_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LRESULT e2d::Game::WndProc(HWND hwnd, UINT msg, WPARAM w_param, LPARAM l_param)
|
LRESULT easy2d::Game::WndProc(HWND hwnd, UINT msg, WPARAM w_param, LPARAM l_param)
|
||||||
{
|
{
|
||||||
LRESULT result = 0;
|
LRESULT result = 0;
|
||||||
bool was_handled = false;
|
bool was_handled = false;
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
#include "..\e2dobject.h"
|
#include "..\e2dobject.h"
|
||||||
|
|
||||||
|
|
||||||
e2d::Graphics::Graphics(HWND hwnd)
|
easy2d::Graphics::Graphics(HWND hwnd)
|
||||||
: factory_(nullptr)
|
: factory_(nullptr)
|
||||||
, imaging_factory_(nullptr)
|
, imaging_factory_(nullptr)
|
||||||
, write_factory_(nullptr)
|
, write_factory_(nullptr)
|
||||||
|
|
@ -101,7 +101,7 @@ e2d::Graphics::Graphics(HWND hwnd)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Graphics::~Graphics()
|
easy2d::Graphics::~Graphics()
|
||||||
{
|
{
|
||||||
SafeRelease(fps_text_format_);
|
SafeRelease(fps_text_format_);
|
||||||
SafeRelease(fps_text_layout_);
|
SafeRelease(fps_text_layout_);
|
||||||
|
|
@ -117,13 +117,13 @@ e2d::Graphics::~Graphics()
|
||||||
SafeRelease(write_factory_);
|
SafeRelease(write_factory_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Graphics::BeginDraw()
|
void easy2d::Graphics::BeginDraw()
|
||||||
{
|
{
|
||||||
render_target_->BeginDraw();
|
render_target_->BeginDraw();
|
||||||
render_target_->Clear(clear_color_);
|
render_target_->Clear(clear_color_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Graphics::EndDraw()
|
void easy2d::Graphics::EndDraw()
|
||||||
{
|
{
|
||||||
HRESULT hr = render_target_->EndDraw();
|
HRESULT hr = render_target_->EndDraw();
|
||||||
|
|
||||||
|
|
@ -143,7 +143,7 @@ void e2d::Graphics::EndDraw()
|
||||||
ThrowIfFailed(hr);
|
ThrowIfFailed(hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Graphics::DrawDebugInfo()
|
void easy2d::Graphics::DrawDebugInfo()
|
||||||
{
|
{
|
||||||
static int render_times_ = 0;
|
static int render_times_ = 0;
|
||||||
static Time last_render_time_ = Time::Now();
|
static Time last_render_time_ = Time::Now();
|
||||||
|
|
@ -213,37 +213,37 @@ void e2d::Graphics::DrawDebugInfo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ID2D1HwndRenderTarget * e2d::Graphics::GetRenderTarget() const
|
ID2D1HwndRenderTarget * easy2d::Graphics::GetRenderTarget() const
|
||||||
{
|
{
|
||||||
return render_target_;
|
return render_target_;
|
||||||
}
|
}
|
||||||
|
|
||||||
ID2D1SolidColorBrush * e2d::Graphics::GetSolidBrush() const
|
ID2D1SolidColorBrush * easy2d::Graphics::GetSolidBrush() const
|
||||||
{
|
{
|
||||||
return solid_brush_;
|
return solid_brush_;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::E2DTextRenderer * e2d::Graphics::GetTextRender() const
|
easy2d::E2DTextRenderer * easy2d::Graphics::GetTextRender() const
|
||||||
{
|
{
|
||||||
return text_renderer_;
|
return text_renderer_;
|
||||||
}
|
}
|
||||||
|
|
||||||
ID2D1Factory * e2d::Graphics::GetFactory() const
|
ID2D1Factory * easy2d::Graphics::GetFactory() const
|
||||||
{
|
{
|
||||||
return factory_;
|
return factory_;
|
||||||
}
|
}
|
||||||
|
|
||||||
IWICImagingFactory * e2d::Graphics::GetImagingFactory() const
|
IWICImagingFactory * easy2d::Graphics::GetImagingFactory() const
|
||||||
{
|
{
|
||||||
return imaging_factory_;
|
return imaging_factory_;
|
||||||
}
|
}
|
||||||
|
|
||||||
IDWriteFactory * e2d::Graphics::GetWriteFactory() const
|
IDWriteFactory * easy2d::Graphics::GetWriteFactory() const
|
||||||
{
|
{
|
||||||
return write_factory_;
|
return write_factory_;
|
||||||
}
|
}
|
||||||
|
|
||||||
ID2D1StrokeStyle * e2d::Graphics::GetMiterStrokeStyle()
|
ID2D1StrokeStyle * easy2d::Graphics::GetMiterStrokeStyle()
|
||||||
{
|
{
|
||||||
if (!miter_stroke_style_)
|
if (!miter_stroke_style_)
|
||||||
{
|
{
|
||||||
|
|
@ -266,7 +266,7 @@ ID2D1StrokeStyle * e2d::Graphics::GetMiterStrokeStyle()
|
||||||
return miter_stroke_style_;
|
return miter_stroke_style_;
|
||||||
}
|
}
|
||||||
|
|
||||||
ID2D1StrokeStyle * e2d::Graphics::GetBevelStrokeStyle()
|
ID2D1StrokeStyle * easy2d::Graphics::GetBevelStrokeStyle()
|
||||||
{
|
{
|
||||||
if (!bevel_stroke_style_)
|
if (!bevel_stroke_style_)
|
||||||
{
|
{
|
||||||
|
|
@ -289,7 +289,7 @@ ID2D1StrokeStyle * e2d::Graphics::GetBevelStrokeStyle()
|
||||||
return bevel_stroke_style_;
|
return bevel_stroke_style_;
|
||||||
}
|
}
|
||||||
|
|
||||||
ID2D1StrokeStyle * e2d::Graphics::GetRoundStrokeStyle()
|
ID2D1StrokeStyle * easy2d::Graphics::GetRoundStrokeStyle()
|
||||||
{
|
{
|
||||||
if (!round_stroke_style_)
|
if (!round_stroke_style_)
|
||||||
{
|
{
|
||||||
|
|
@ -312,7 +312,7 @@ ID2D1StrokeStyle * e2d::Graphics::GetRoundStrokeStyle()
|
||||||
return round_stroke_style_;
|
return round_stroke_style_;
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Graphics::GetDpi()
|
float easy2d::Graphics::GetDpi()
|
||||||
{
|
{
|
||||||
HDC hdc = ::GetDC(0);
|
HDC hdc = ::GetDC(0);
|
||||||
int dpi = ::GetDeviceCaps(hdc, LOGPIXELSX);
|
int dpi = ::GetDeviceCaps(hdc, LOGPIXELSX);
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
#include "..\e2dtool.h"
|
#include "..\e2dtool.h"
|
||||||
|
|
||||||
|
|
||||||
e2d::Input::Input(HWND hwnd)
|
easy2d::Input::Input(HWND hwnd)
|
||||||
: direct_input_(nullptr)
|
: direct_input_(nullptr)
|
||||||
, keyboard_device_(nullptr)
|
, keyboard_device_(nullptr)
|
||||||
, mouse_device_(nullptr)
|
, mouse_device_(nullptr)
|
||||||
|
|
@ -70,7 +70,7 @@ e2d::Input::Input(HWND hwnd)
|
||||||
mouse_device_->Poll();
|
mouse_device_->Poll();
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Input::~Input()
|
easy2d::Input::~Input()
|
||||||
{
|
{
|
||||||
if (keyboard_device_)
|
if (keyboard_device_)
|
||||||
keyboard_device_->Unacquire();
|
keyboard_device_->Unacquire();
|
||||||
|
|
@ -82,7 +82,7 @@ e2d::Input::~Input()
|
||||||
SafeRelease(direct_input_);
|
SafeRelease(direct_input_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Input::Flush()
|
void easy2d::Input::Flush()
|
||||||
{
|
{
|
||||||
if (keyboard_device_)
|
if (keyboard_device_)
|
||||||
{
|
{
|
||||||
|
|
@ -121,31 +121,31 @@ void e2d::Input::Flush()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Input::IsDown(KeyCode key)
|
bool easy2d::Input::IsDown(KeyCode key)
|
||||||
{
|
{
|
||||||
if (key_buffer_[static_cast<int>(key)] & 0x80)
|
if (key_buffer_[static_cast<int>(key)] & 0x80)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Input::IsDown(MouseCode code)
|
bool easy2d::Input::IsDown(MouseCode code)
|
||||||
{
|
{
|
||||||
if (mouse_state_.rgbButtons[static_cast<int>(code)] & 0x80)
|
if (mouse_state_.rgbButtons[static_cast<int>(code)] & 0x80)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Input::GetMouseX()
|
float easy2d::Input::GetMouseX()
|
||||||
{
|
{
|
||||||
return GetMousePos().x;
|
return GetMousePos().x;
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Input::GetMouseY()
|
float easy2d::Input::GetMouseY()
|
||||||
{
|
{
|
||||||
return GetMousePos().y;
|
return GetMousePos().y;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Point e2d::Input::GetMousePos()
|
easy2d::Point easy2d::Input::GetMousePos()
|
||||||
{
|
{
|
||||||
POINT mousePos;
|
POINT mousePos;
|
||||||
::GetCursorPos(&mousePos);
|
::GetCursorPos(&mousePos);
|
||||||
|
|
@ -154,17 +154,17 @@ e2d::Point e2d::Input::GetMousePos()
|
||||||
return Point(mousePos.x * 96.f / dpi, mousePos.y * 96.f / dpi);
|
return Point(mousePos.x * 96.f / dpi, mousePos.y * 96.f / dpi);
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Input::GetMouseDeltaX()
|
float easy2d::Input::GetMouseDeltaX()
|
||||||
{
|
{
|
||||||
return (float)mouse_state_.lX;
|
return (float)mouse_state_.lX;
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Input::GetMouseDeltaY()
|
float easy2d::Input::GetMouseDeltaY()
|
||||||
{
|
{
|
||||||
return (float)mouse_state_.lY;
|
return (float)mouse_state_.lY;
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Input::GetMouseDeltaZ()
|
float easy2d::Input::GetMouseDeltaZ()
|
||||||
{
|
{
|
||||||
return (float)mouse_state_.lZ;
|
return (float)mouse_state_.lZ;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
#include "..\e2dobject.h"
|
#include "..\e2dobject.h"
|
||||||
#include "..\e2dmodule.h"
|
#include "..\e2dmodule.h"
|
||||||
|
|
||||||
e2d::Canvas::Canvas(float width, float height)
|
easy2d::Canvas::Canvas(float width, float height)
|
||||||
: render_target_(nullptr)
|
: render_target_(nullptr)
|
||||||
, fill_brush_(nullptr)
|
, fill_brush_(nullptr)
|
||||||
, line_brush_(nullptr)
|
, line_brush_(nullptr)
|
||||||
|
|
@ -52,65 +52,65 @@ e2d::Canvas::Canvas(float width, float height)
|
||||||
this->SetStrokeStyle(stroke_);
|
this->SetStrokeStyle(stroke_);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Canvas::~Canvas()
|
easy2d::Canvas::~Canvas()
|
||||||
{
|
{
|
||||||
SafeRelease(line_brush_);
|
SafeRelease(line_brush_);
|
||||||
SafeRelease(fill_brush_);
|
SafeRelease(fill_brush_);
|
||||||
SafeRelease(render_target_);
|
SafeRelease(render_target_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Canvas::SetLineColor(const Color & color)
|
void easy2d::Canvas::SetLineColor(const Color & color)
|
||||||
{
|
{
|
||||||
line_brush_->SetColor(D2D_COLOR_F(color));
|
line_brush_->SetColor(D2D_COLOR_F(color));
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Canvas::SetFillColor(const Color & color)
|
void easy2d::Canvas::SetFillColor(const Color & color)
|
||||||
{
|
{
|
||||||
fill_brush_->SetColor(D2D_COLOR_F(color));
|
fill_brush_->SetColor(D2D_COLOR_F(color));
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Canvas::SetStrokeWidth(float width)
|
void easy2d::Canvas::SetStrokeWidth(float width)
|
||||||
{
|
{
|
||||||
stroke_width_ = std::max(width, 0.f);
|
stroke_width_ = std::max(width, 0.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Canvas::SetStrokeStyle(Stroke strokeStyle)
|
void easy2d::Canvas::SetStrokeStyle(Stroke strokeStyle)
|
||||||
{
|
{
|
||||||
switch (strokeStyle)
|
switch (strokeStyle)
|
||||||
{
|
{
|
||||||
case e2d::Stroke::Miter:
|
case easy2d::Stroke::Miter:
|
||||||
stroke_style_ = Device::GetGraphics()->GetMiterStrokeStyle();
|
stroke_style_ = Device::GetGraphics()->GetMiterStrokeStyle();
|
||||||
break;
|
break;
|
||||||
case e2d::Stroke::Bevel:
|
case easy2d::Stroke::Bevel:
|
||||||
stroke_style_ = Device::GetGraphics()->GetBevelStrokeStyle();
|
stroke_style_ = Device::GetGraphics()->GetBevelStrokeStyle();
|
||||||
break;
|
break;
|
||||||
case e2d::Stroke::Round:
|
case easy2d::Stroke::Round:
|
||||||
stroke_style_ = Device::GetGraphics()->GetRoundStrokeStyle();
|
stroke_style_ = Device::GetGraphics()->GetRoundStrokeStyle();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Color e2d::Canvas::GetLineColor() const
|
easy2d::Color easy2d::Canvas::GetLineColor() const
|
||||||
{
|
{
|
||||||
return line_brush_->GetColor();
|
return line_brush_->GetColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Color e2d::Canvas::GetFillColor() const
|
easy2d::Color easy2d::Canvas::GetFillColor() const
|
||||||
{
|
{
|
||||||
return fill_brush_->GetColor();
|
return fill_brush_->GetColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Canvas::GetStrokeWidth() const
|
float easy2d::Canvas::GetStrokeWidth() const
|
||||||
{
|
{
|
||||||
return stroke_width_;
|
return stroke_width_;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Stroke e2d::Canvas::GetStrokeStyle() const
|
easy2d::Stroke easy2d::Canvas::GetStrokeStyle() const
|
||||||
{
|
{
|
||||||
return stroke_;
|
return stroke_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Canvas::DrawLine(const Point & begin, const Point & end)
|
void easy2d::Canvas::DrawLine(const Point & begin, const Point & end)
|
||||||
{
|
{
|
||||||
render_target_->DrawLine(
|
render_target_->DrawLine(
|
||||||
D2D1::Point2F(begin.x, begin.y),
|
D2D1::Point2F(begin.x, begin.y),
|
||||||
|
|
@ -121,7 +121,7 @@ void e2d::Canvas::DrawLine(const Point & begin, const Point & end)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Canvas::DrawCircle(const Point & center, float radius)
|
void easy2d::Canvas::DrawCircle(const Point & center, float radius)
|
||||||
{
|
{
|
||||||
render_target_->DrawEllipse(
|
render_target_->DrawEllipse(
|
||||||
D2D1::Ellipse(
|
D2D1::Ellipse(
|
||||||
|
|
@ -138,7 +138,7 @@ void e2d::Canvas::DrawCircle(const Point & center, float radius)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Canvas::DrawEllipse(const Point & center, float radius_x, float radius_y)
|
void easy2d::Canvas::DrawEllipse(const Point & center, float radius_x, float radius_y)
|
||||||
{
|
{
|
||||||
render_target_->DrawEllipse(
|
render_target_->DrawEllipse(
|
||||||
D2D1::Ellipse(
|
D2D1::Ellipse(
|
||||||
|
|
@ -155,7 +155,7 @@ void e2d::Canvas::DrawEllipse(const Point & center, float radius_x, float radius
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Canvas::DrawRect(const Rect & rect)
|
void easy2d::Canvas::DrawRect(const Rect & rect)
|
||||||
{
|
{
|
||||||
render_target_->DrawRectangle(
|
render_target_->DrawRectangle(
|
||||||
D2D1::RectF(
|
D2D1::RectF(
|
||||||
|
|
@ -170,7 +170,7 @@ void e2d::Canvas::DrawRect(const Rect & rect)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Canvas::DrawRoundedRect(const Rect & rect, float radius_x, float radius_y)
|
void easy2d::Canvas::DrawRoundedRect(const Rect & rect, float radius_x, float radius_y)
|
||||||
{
|
{
|
||||||
render_target_->DrawRoundedRectangle(
|
render_target_->DrawRoundedRectangle(
|
||||||
D2D1::RoundedRect(
|
D2D1::RoundedRect(
|
||||||
|
|
@ -189,7 +189,7 @@ void e2d::Canvas::DrawRoundedRect(const Rect & rect, float radius_x, float radiu
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Canvas::FillCircle(const Point & center, float radius)
|
void easy2d::Canvas::FillCircle(const Point & center, float radius)
|
||||||
{
|
{
|
||||||
render_target_->FillEllipse(
|
render_target_->FillEllipse(
|
||||||
D2D1::Ellipse(
|
D2D1::Ellipse(
|
||||||
|
|
@ -204,7 +204,7 @@ void e2d::Canvas::FillCircle(const Point & center, float radius)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Canvas::FillEllipse(const Point & center, float radius_x, float radius_y)
|
void easy2d::Canvas::FillEllipse(const Point & center, float radius_x, float radius_y)
|
||||||
{
|
{
|
||||||
render_target_->FillEllipse(
|
render_target_->FillEllipse(
|
||||||
D2D1::Ellipse(
|
D2D1::Ellipse(
|
||||||
|
|
@ -219,7 +219,7 @@ void e2d::Canvas::FillEllipse(const Point & center, float radius_x, float radius
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Canvas::FillRect(const Rect & rect)
|
void easy2d::Canvas::FillRect(const Rect & rect)
|
||||||
{
|
{
|
||||||
render_target_->FillRectangle(
|
render_target_->FillRectangle(
|
||||||
D2D1::RectF(
|
D2D1::RectF(
|
||||||
|
|
@ -232,7 +232,7 @@ void e2d::Canvas::FillRect(const Rect & rect)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Canvas::FillRoundedRect(const Rect & rect, float radius_x, float radius_y)
|
void easy2d::Canvas::FillRoundedRect(const Rect & rect, float radius_x, float radius_y)
|
||||||
{
|
{
|
||||||
render_target_->FillRoundedRectangle(
|
render_target_->FillRoundedRectangle(
|
||||||
D2D1::RoundedRect(
|
D2D1::RoundedRect(
|
||||||
|
|
|
||||||
|
|
@ -22,22 +22,22 @@
|
||||||
#include "..\e2dmodule.h"
|
#include "..\e2dmodule.h"
|
||||||
#include "..\e2dtool.h"
|
#include "..\e2dtool.h"
|
||||||
|
|
||||||
std::map<size_t, ID2D1Bitmap*> e2d::Image::bitmap_cache_;
|
std::map<size_t, ID2D1Bitmap*> easy2d::Image::bitmap_cache_;
|
||||||
|
|
||||||
e2d::Image::Image()
|
easy2d::Image::Image()
|
||||||
: bitmap_(nullptr)
|
: bitmap_(nullptr)
|
||||||
, crop_rect_()
|
, crop_rect_()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Image::Image(const Resource& res)
|
easy2d::Image::Image(const Resource& res)
|
||||||
: bitmap_(nullptr)
|
: bitmap_(nullptr)
|
||||||
, crop_rect_()
|
, crop_rect_()
|
||||||
{
|
{
|
||||||
this->Load(res);
|
this->Load(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Image::Image(const Resource& res, const Rect& crop_rect)
|
easy2d::Image::Image(const Resource& res, const Rect& crop_rect)
|
||||||
: bitmap_(nullptr)
|
: bitmap_(nullptr)
|
||||||
, crop_rect_()
|
, crop_rect_()
|
||||||
{
|
{
|
||||||
|
|
@ -45,14 +45,14 @@ e2d::Image::Image(const Resource& res, const Rect& crop_rect)
|
||||||
this->Crop(crop_rect);
|
this->Crop(crop_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Image::Image(const String & file_name)
|
easy2d::Image::Image(const String & file_name)
|
||||||
: bitmap_(nullptr)
|
: bitmap_(nullptr)
|
||||||
, crop_rect_()
|
, crop_rect_()
|
||||||
{
|
{
|
||||||
this->Load(file_name);
|
this->Load(file_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Image::Image(const String & file_name, const Rect & crop_rect)
|
easy2d::Image::Image(const String & file_name, const Rect & crop_rect)
|
||||||
: bitmap_(nullptr)
|
: bitmap_(nullptr)
|
||||||
, crop_rect_()
|
, crop_rect_()
|
||||||
{
|
{
|
||||||
|
|
@ -60,12 +60,12 @@ e2d::Image::Image(const String & file_name, const Rect & crop_rect)
|
||||||
this->Crop(crop_rect);
|
this->Crop(crop_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Image::~Image()
|
easy2d::Image::~Image()
|
||||||
{
|
{
|
||||||
SafeRelease(bitmap_);
|
SafeRelease(bitmap_);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Image::Load(const Resource& res)
|
bool easy2d::Image::Load(const Resource& res)
|
||||||
{
|
{
|
||||||
if (!Image::CacheBitmap(res))
|
if (!Image::CacheBitmap(res))
|
||||||
{
|
{
|
||||||
|
|
@ -77,7 +77,7 @@ bool e2d::Image::Load(const Resource& res)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Image::Load(const String & file_name)
|
bool easy2d::Image::Load(const String & file_name)
|
||||||
{
|
{
|
||||||
WARN_IF(file_name.IsEmpty(), "Image Load failed! Invalid file name.");
|
WARN_IF(file_name.IsEmpty(), "Image Load failed! Invalid file name.");
|
||||||
|
|
||||||
|
|
@ -94,7 +94,7 @@ bool e2d::Image::Load(const String & file_name)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Image::Crop(const Rect& crop_rect)
|
void easy2d::Image::Crop(const Rect& crop_rect)
|
||||||
{
|
{
|
||||||
if (bitmap_)
|
if (bitmap_)
|
||||||
{
|
{
|
||||||
|
|
@ -106,22 +106,22 @@ void e2d::Image::Crop(const Rect& crop_rect)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Image::GetWidth() const
|
float easy2d::Image::GetWidth() const
|
||||||
{
|
{
|
||||||
return crop_rect_.size.width;
|
return crop_rect_.size.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Image::GetHeight() const
|
float easy2d::Image::GetHeight() const
|
||||||
{
|
{
|
||||||
return crop_rect_.size.height;
|
return crop_rect_.size.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Size e2d::Image::GetSize() const
|
easy2d::Size easy2d::Image::GetSize() const
|
||||||
{
|
{
|
||||||
return crop_rect_.size;
|
return crop_rect_.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Image::GetSourceWidth() const
|
float easy2d::Image::GetSourceWidth() const
|
||||||
{
|
{
|
||||||
if (bitmap_)
|
if (bitmap_)
|
||||||
{
|
{
|
||||||
|
|
@ -133,7 +133,7 @@ float e2d::Image::GetSourceWidth() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Image::GetSourceHeight() const
|
float easy2d::Image::GetSourceHeight() const
|
||||||
{
|
{
|
||||||
if (bitmap_)
|
if (bitmap_)
|
||||||
{
|
{
|
||||||
|
|
@ -145,7 +145,7 @@ float e2d::Image::GetSourceHeight() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Size e2d::Image::GetSourceSize() const
|
easy2d::Size easy2d::Image::GetSourceSize() const
|
||||||
{
|
{
|
||||||
Size source_size;
|
Size source_size;
|
||||||
if (bitmap_)
|
if (bitmap_)
|
||||||
|
|
@ -157,32 +157,32 @@ e2d::Size e2d::Image::GetSourceSize() const
|
||||||
return std::move(source_size);
|
return std::move(source_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Image::GetCropX() const
|
float easy2d::Image::GetCropX() const
|
||||||
{
|
{
|
||||||
return crop_rect_.origin.x;
|
return crop_rect_.origin.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Image::GetCropY() const
|
float easy2d::Image::GetCropY() const
|
||||||
{
|
{
|
||||||
return crop_rect_.origin.y;
|
return crop_rect_.origin.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Point e2d::Image::GetCropPos() const
|
easy2d::Point easy2d::Image::GetCropPos() const
|
||||||
{
|
{
|
||||||
return crop_rect_.origin;
|
return crop_rect_.origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
const e2d::Rect & e2d::Image::GetCropRect() const
|
const easy2d::Rect & easy2d::Image::GetCropRect() const
|
||||||
{
|
{
|
||||||
return crop_rect_;
|
return crop_rect_;
|
||||||
}
|
}
|
||||||
|
|
||||||
ID2D1Bitmap * e2d::Image::GetBitmap() const
|
ID2D1Bitmap * easy2d::Image::GetBitmap() const
|
||||||
{
|
{
|
||||||
return bitmap_;
|
return bitmap_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Image::CacheBitmap(const Resource& res)
|
bool easy2d::Image::CacheBitmap(const Resource& res)
|
||||||
{
|
{
|
||||||
if (bitmap_cache_.find(res.id) != bitmap_cache_.end())
|
if (bitmap_cache_.find(res.id) != bitmap_cache_.end())
|
||||||
{
|
{
|
||||||
|
|
@ -308,7 +308,7 @@ bool e2d::Image::CacheBitmap(const Resource& res)
|
||||||
return SUCCEEDED(hr);
|
return SUCCEEDED(hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Image::CacheBitmap(const String & file_name)
|
bool easy2d::Image::CacheBitmap(const String & file_name)
|
||||||
{
|
{
|
||||||
size_t hash = file_name.GetHash();
|
size_t hash = file_name.GetHash();
|
||||||
if (bitmap_cache_.find(hash) != bitmap_cache_.end())
|
if (bitmap_cache_.find(hash) != bitmap_cache_.end())
|
||||||
|
|
@ -389,7 +389,7 @@ bool e2d::Image::CacheBitmap(const String & file_name)
|
||||||
return SUCCEEDED(hr);
|
return SUCCEEDED(hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Image::ClearCache()
|
void easy2d::Image::ClearCache()
|
||||||
{
|
{
|
||||||
if (bitmap_cache_.empty())
|
if (bitmap_cache_.empty())
|
||||||
return;
|
return;
|
||||||
|
|
@ -401,7 +401,7 @@ void e2d::Image::ClearCache()
|
||||||
bitmap_cache_.clear();
|
bitmap_cache_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Image::SetBitmap(ID2D1Bitmap * bitmap)
|
void easy2d::Image::SetBitmap(ID2D1Bitmap * bitmap)
|
||||||
{
|
{
|
||||||
if (bitmap_ == bitmap)
|
if (bitmap_ == bitmap)
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
#include "..\e2dmodule.h"
|
#include "..\e2dmodule.h"
|
||||||
|
|
||||||
|
|
||||||
e2d::Node::Node()
|
easy2d::Node::Node()
|
||||||
: visible_(true)
|
: visible_(true)
|
||||||
, parent_(nullptr)
|
, parent_(nullptr)
|
||||||
, parent_scene_(nullptr)
|
, parent_scene_(nullptr)
|
||||||
|
|
@ -46,7 +46,7 @@ e2d::Node::Node()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Node::~Node()
|
easy2d::Node::~Node()
|
||||||
{
|
{
|
||||||
SafeRelease(border_);
|
SafeRelease(border_);
|
||||||
|
|
||||||
|
|
@ -66,7 +66,7 @@ e2d::Node::~Node()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::Visit()
|
void easy2d::Node::Visit()
|
||||||
{
|
{
|
||||||
if (!visible_)
|
if (!visible_)
|
||||||
return;
|
return;
|
||||||
|
|
@ -129,7 +129,7 @@ void e2d::Node::Visit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::UpdateChildren(float dt)
|
void easy2d::Node::UpdateChildren(float dt)
|
||||||
{
|
{
|
||||||
if (children_.empty())
|
if (children_.empty())
|
||||||
{
|
{
|
||||||
|
|
@ -166,7 +166,7 @@ void e2d::Node::UpdateChildren(float dt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::DrawBorder()
|
void easy2d::Node::DrawBorder()
|
||||||
{
|
{
|
||||||
if (visible_)
|
if (visible_)
|
||||||
{
|
{
|
||||||
|
|
@ -189,7 +189,7 @@ void e2d::Node::DrawBorder()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::UpdateTransform()
|
void easy2d::Node::UpdateTransform()
|
||||||
{
|
{
|
||||||
if (!dirty_transform_)
|
if (!dirty_transform_)
|
||||||
return;
|
return;
|
||||||
|
|
@ -246,7 +246,7 @@ void e2d::Node::UpdateTransform()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Node::Dispatch(const MouseEvent & e, bool handled)
|
bool easy2d::Node::Dispatch(const MouseEvent & e, bool handled)
|
||||||
{
|
{
|
||||||
if (visible_)
|
if (visible_)
|
||||||
{
|
{
|
||||||
|
|
@ -261,7 +261,7 @@ bool e2d::Node::Dispatch(const MouseEvent & e, bool handled)
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Node::Dispatch(const KeyEvent & e, bool handled)
|
bool easy2d::Node::Dispatch(const KeyEvent & e, bool handled)
|
||||||
{
|
{
|
||||||
if (visible_)
|
if (visible_)
|
||||||
{
|
{
|
||||||
|
|
@ -276,7 +276,7 @@ bool e2d::Node::Dispatch(const KeyEvent & e, bool handled)
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::UpdateOpacity()
|
void easy2d::Node::UpdateOpacity()
|
||||||
{
|
{
|
||||||
if (parent_)
|
if (parent_)
|
||||||
{
|
{
|
||||||
|
|
@ -288,7 +288,7 @@ void e2d::Node::UpdateOpacity()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::UpdateActions()
|
void easy2d::Node::UpdateActions()
|
||||||
{
|
{
|
||||||
if (actions_.empty())
|
if (actions_.empty())
|
||||||
return;
|
return;
|
||||||
|
|
@ -321,107 +321,107 @@ void e2d::Node::UpdateActions()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Node::IsVisible() const
|
bool easy2d::Node::IsVisible() const
|
||||||
{
|
{
|
||||||
return visible_;
|
return visible_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const e2d::String& e2d::Node::GetName() const
|
const easy2d::String& easy2d::Node::GetName() const
|
||||||
{
|
{
|
||||||
return name_;
|
return name_;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t e2d::Node::GetHashName() const
|
size_t easy2d::Node::GetHashName() const
|
||||||
{
|
{
|
||||||
return hash_name_;
|
return hash_name_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const e2d::Point& e2d::Node::GetPosition() const
|
const easy2d::Point& easy2d::Node::GetPosition() const
|
||||||
{
|
{
|
||||||
return transform_.position;
|
return transform_.position;
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Node::GetWidth() const
|
float easy2d::Node::GetWidth() const
|
||||||
{
|
{
|
||||||
return transform_.size.width * transform_.scale_x;
|
return transform_.size.width * transform_.scale_x;
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Node::GetHeight() const
|
float easy2d::Node::GetHeight() const
|
||||||
{
|
{
|
||||||
return transform_.size.height * transform_.scale_y;
|
return transform_.size.height * transform_.scale_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Node::GetRealWidth() const
|
float easy2d::Node::GetRealWidth() const
|
||||||
{
|
{
|
||||||
return transform_.size.width;
|
return transform_.size.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Node::GetRealHeight() const
|
float easy2d::Node::GetRealHeight() const
|
||||||
{
|
{
|
||||||
return transform_.size.height;
|
return transform_.size.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
const e2d::Size& e2d::Node::GetRealSize() const
|
const easy2d::Size& easy2d::Node::GetRealSize() const
|
||||||
{
|
{
|
||||||
return transform_.size;
|
return transform_.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Node::GetPivotX() const
|
float easy2d::Node::GetPivotX() const
|
||||||
{
|
{
|
||||||
return transform_.pivot_x;
|
return transform_.pivot_x;
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Node::GetPivotY() const
|
float easy2d::Node::GetPivotY() const
|
||||||
{
|
{
|
||||||
return transform_.pivot_y;
|
return transform_.pivot_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Size e2d::Node::GetSize() const
|
easy2d::Size easy2d::Node::GetSize() const
|
||||||
{
|
{
|
||||||
return std::move(Size(GetWidth(), GetHeight()));
|
return std::move(Size(GetWidth(), GetHeight()));
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Node::GetScaleX() const
|
float easy2d::Node::GetScaleX() const
|
||||||
{
|
{
|
||||||
return transform_.scale_x;
|
return transform_.scale_x;
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Node::GetScaleY() const
|
float easy2d::Node::GetScaleY() const
|
||||||
{
|
{
|
||||||
return transform_.scale_y;
|
return transform_.scale_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Node::GetSkewX() const
|
float easy2d::Node::GetSkewX() const
|
||||||
{
|
{
|
||||||
return transform_.skew_x;
|
return transform_.skew_x;
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Node::GetSkewY() const
|
float easy2d::Node::GetSkewY() const
|
||||||
{
|
{
|
||||||
return transform_.skew_y;
|
return transform_.skew_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Node::GetRotation() const
|
float easy2d::Node::GetRotation() const
|
||||||
{
|
{
|
||||||
return transform_.rotation;
|
return transform_.rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
const e2d::Transform & e2d::Node::GetTransform() const
|
const easy2d::Transform & easy2d::Node::GetTransform() const
|
||||||
{
|
{
|
||||||
return transform_;
|
return transform_;
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Node::GetOpacity() const
|
float easy2d::Node::GetOpacity() const
|
||||||
{
|
{
|
||||||
return real_opacity_;
|
return real_opacity_;
|
||||||
}
|
}
|
||||||
|
|
||||||
int e2d::Node::GetOrder() const
|
int easy2d::Node::GetOrder() const
|
||||||
{
|
{
|
||||||
return order_;
|
return order_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::SetOrder(int order)
|
void easy2d::Node::SetOrder(int order)
|
||||||
{
|
{
|
||||||
if (order_ == order)
|
if (order_ == order)
|
||||||
return;
|
return;
|
||||||
|
|
@ -433,22 +433,22 @@ void e2d::Node::SetOrder(int order)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::SetPositionX(float x)
|
void easy2d::Node::SetPositionX(float x)
|
||||||
{
|
{
|
||||||
this->SetPosition(x, transform_.position.y);
|
this->SetPosition(x, transform_.position.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::SetPositionY(float y)
|
void easy2d::Node::SetPositionY(float y)
|
||||||
{
|
{
|
||||||
this->SetPosition(transform_.position.x, y);
|
this->SetPosition(transform_.position.x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::SetPosition(const Point & p)
|
void easy2d::Node::SetPosition(const Point & p)
|
||||||
{
|
{
|
||||||
this->SetPosition(p.x, p.y);
|
this->SetPosition(p.x, p.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::SetPosition(float x, float y)
|
void easy2d::Node::SetPosition(float x, float y)
|
||||||
{
|
{
|
||||||
if (transform_.position.x == x && transform_.position.y == y)
|
if (transform_.position.x == x && transform_.position.y == y)
|
||||||
return;
|
return;
|
||||||
|
|
@ -458,32 +458,32 @@ void e2d::Node::SetPosition(float x, float y)
|
||||||
dirty_transform_ = true;
|
dirty_transform_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::MoveBy(float x, float y)
|
void easy2d::Node::MoveBy(float x, float y)
|
||||||
{
|
{
|
||||||
this->SetPosition(transform_.position.x + x, transform_.position.y + y);
|
this->SetPosition(transform_.position.x + x, transform_.position.y + y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::MoveBy(const Point & v)
|
void easy2d::Node::MoveBy(const Point & v)
|
||||||
{
|
{
|
||||||
this->MoveBy(v.x, v.y);
|
this->MoveBy(v.x, v.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::SetScaleX(float scale_x)
|
void easy2d::Node::SetScaleX(float scale_x)
|
||||||
{
|
{
|
||||||
this->SetScale(scale_x, transform_.scale_y);
|
this->SetScale(scale_x, transform_.scale_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::SetScaleY(float scale_y)
|
void easy2d::Node::SetScaleY(float scale_y)
|
||||||
{
|
{
|
||||||
this->SetScale(transform_.scale_x, scale_y);
|
this->SetScale(transform_.scale_x, scale_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::SetScale(float scale)
|
void easy2d::Node::SetScale(float scale)
|
||||||
{
|
{
|
||||||
this->SetScale(scale, scale);
|
this->SetScale(scale, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::SetScale(float scale_x, float scale_y)
|
void easy2d::Node::SetScale(float scale_x, float scale_y)
|
||||||
{
|
{
|
||||||
if (transform_.scale_x == scale_x && transform_.scale_y == scale_y)
|
if (transform_.scale_x == scale_x && transform_.scale_y == scale_y)
|
||||||
return;
|
return;
|
||||||
|
|
@ -493,17 +493,17 @@ void e2d::Node::SetScale(float scale_x, float scale_y)
|
||||||
dirty_transform_ = true;
|
dirty_transform_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::SetSkewX(float skew_x)
|
void easy2d::Node::SetSkewX(float skew_x)
|
||||||
{
|
{
|
||||||
this->SetSkew(skew_x, transform_.skew_y);
|
this->SetSkew(skew_x, transform_.skew_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::SetSkewY(float skew_y)
|
void easy2d::Node::SetSkewY(float skew_y)
|
||||||
{
|
{
|
||||||
this->SetSkew(transform_.skew_x, skew_y);
|
this->SetSkew(transform_.skew_x, skew_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::SetSkew(float skew_x, float skew_y)
|
void easy2d::Node::SetSkew(float skew_x, float skew_y)
|
||||||
{
|
{
|
||||||
if (transform_.skew_x == skew_x && transform_.skew_y == skew_y)
|
if (transform_.skew_x == skew_x && transform_.skew_y == skew_y)
|
||||||
return;
|
return;
|
||||||
|
|
@ -513,7 +513,7 @@ void e2d::Node::SetSkew(float skew_x, float skew_y)
|
||||||
dirty_transform_ = true;
|
dirty_transform_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::SetRotation(float angle)
|
void easy2d::Node::SetRotation(float angle)
|
||||||
{
|
{
|
||||||
if (transform_.rotation == angle)
|
if (transform_.rotation == angle)
|
||||||
return;
|
return;
|
||||||
|
|
@ -522,7 +522,7 @@ void e2d::Node::SetRotation(float angle)
|
||||||
dirty_transform_ = true;
|
dirty_transform_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::SetOpacity(float opacity)
|
void easy2d::Node::SetOpacity(float opacity)
|
||||||
{
|
{
|
||||||
if (real_opacity_ == opacity)
|
if (real_opacity_ == opacity)
|
||||||
return;
|
return;
|
||||||
|
|
@ -532,17 +532,17 @@ void e2d::Node::SetOpacity(float opacity)
|
||||||
UpdateOpacity();
|
UpdateOpacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::SetPivotX(float pivot_x)
|
void easy2d::Node::SetPivotX(float pivot_x)
|
||||||
{
|
{
|
||||||
this->SetPivot(pivot_x, transform_.pivot_y);
|
this->SetPivot(pivot_x, transform_.pivot_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::SetPivotY(float pivot_y)
|
void easy2d::Node::SetPivotY(float pivot_y)
|
||||||
{
|
{
|
||||||
this->SetPivot(transform_.pivot_x, pivot_y);
|
this->SetPivot(transform_.pivot_x, pivot_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::SetPivot(float pivot_x, float pivot_y)
|
void easy2d::Node::SetPivot(float pivot_x, float pivot_y)
|
||||||
{
|
{
|
||||||
if (transform_.pivot_x == pivot_x && transform_.pivot_y == pivot_y)
|
if (transform_.pivot_x == pivot_x && transform_.pivot_y == pivot_y)
|
||||||
return;
|
return;
|
||||||
|
|
@ -552,17 +552,17 @@ void e2d::Node::SetPivot(float pivot_x, float pivot_y)
|
||||||
dirty_transform_ = true;
|
dirty_transform_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::SetWidth(float width)
|
void easy2d::Node::SetWidth(float width)
|
||||||
{
|
{
|
||||||
this->SetSize(width, transform_.size.height);
|
this->SetSize(width, transform_.size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::SetHeight(float height)
|
void easy2d::Node::SetHeight(float height)
|
||||||
{
|
{
|
||||||
this->SetSize(transform_.size.width, height);
|
this->SetSize(transform_.size.width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::SetSize(float width, float height)
|
void easy2d::Node::SetSize(float width, float height)
|
||||||
{
|
{
|
||||||
if (transform_.size.width == width && transform_.size.height == height)
|
if (transform_.size.width == width && transform_.size.height == height)
|
||||||
return;
|
return;
|
||||||
|
|
@ -572,28 +572,28 @@ void e2d::Node::SetSize(float width, float height)
|
||||||
dirty_transform_ = true;
|
dirty_transform_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::SetSize(const Size& size)
|
void easy2d::Node::SetSize(const Size& size)
|
||||||
{
|
{
|
||||||
this->SetSize(size.width, size.height);
|
this->SetSize(size.width, size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::SetTransform(const Transform & transform)
|
void easy2d::Node::SetTransform(const Transform & transform)
|
||||||
{
|
{
|
||||||
transform_ = transform;
|
transform_ = transform;
|
||||||
dirty_transform_ = true;
|
dirty_transform_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::SetClipEnabled(bool enabled)
|
void easy2d::Node::SetClipEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
clip_enabled_ = enabled;
|
clip_enabled_ = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::SetBorderColor(const Color & color)
|
void easy2d::Node::SetBorderColor(const Color & color)
|
||||||
{
|
{
|
||||||
border_color_ = color;
|
border_color_ = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::AddChild(Node * child, int order)
|
void easy2d::Node::AddChild(Node * child, int order)
|
||||||
{
|
{
|
||||||
WARN_IF(child == nullptr, "Node::AddChild NULL pointer exception.");
|
WARN_IF(child == nullptr, "Node::AddChild NULL pointer exception.");
|
||||||
|
|
||||||
|
|
@ -630,7 +630,7 @@ void e2d::Node::AddChild(Node * child, int order)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::AddChild(const Nodes& nodes, int order)
|
void easy2d::Node::AddChild(const Nodes& nodes, int order)
|
||||||
{
|
{
|
||||||
for (const auto& node : nodes)
|
for (const auto& node : nodes)
|
||||||
{
|
{
|
||||||
|
|
@ -638,17 +638,17 @@ void e2d::Node::AddChild(const Nodes& nodes, int order)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Node * e2d::Node::GetParent() const
|
easy2d::Node * easy2d::Node::GetParent() const
|
||||||
{
|
{
|
||||||
return parent_;
|
return parent_;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Scene * e2d::Node::GetParentScene() const
|
easy2d::Scene * easy2d::Node::GetParentScene() const
|
||||||
{
|
{
|
||||||
return parent_scene_;
|
return parent_scene_;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Node::Nodes e2d::Node::GetChildren(const String& name) const
|
easy2d::Node::Nodes easy2d::Node::GetChildren(const String& name) const
|
||||||
{
|
{
|
||||||
Nodes children;
|
Nodes children;
|
||||||
size_t hash = name.GetHash();
|
size_t hash = name.GetHash();
|
||||||
|
|
@ -664,7 +664,7 @@ e2d::Node::Nodes e2d::Node::GetChildren(const String& name) const
|
||||||
return std::move(children);
|
return std::move(children);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Node * e2d::Node::GetChild(const String& name) const
|
easy2d::Node * easy2d::Node::GetChild(const String& name) const
|
||||||
{
|
{
|
||||||
size_t hash = name.GetHash();
|
size_t hash = name.GetHash();
|
||||||
|
|
||||||
|
|
@ -679,17 +679,17 @@ e2d::Node * e2d::Node::GetChild(const String& name) const
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<e2d::Node*>& e2d::Node::GetAllChildren() const
|
const std::vector<easy2d::Node*>& easy2d::Node::GetAllChildren() const
|
||||||
{
|
{
|
||||||
return children_;
|
return children_;
|
||||||
}
|
}
|
||||||
|
|
||||||
int e2d::Node::GetChildrenCount() const
|
int easy2d::Node::GetChildrenCount() const
|
||||||
{
|
{
|
||||||
return static_cast<int>(children_.size());
|
return static_cast<int>(children_.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::RemoveFromParent()
|
void easy2d::Node::RemoveFromParent()
|
||||||
{
|
{
|
||||||
if (parent_)
|
if (parent_)
|
||||||
{
|
{
|
||||||
|
|
@ -697,7 +697,7 @@ void e2d::Node::RemoveFromParent()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Node::RemoveChild(Node * child)
|
bool easy2d::Node::RemoveChild(Node * child)
|
||||||
{
|
{
|
||||||
WARN_IF(child == nullptr, "Node::RemoveChildren NULL pointer exception.");
|
WARN_IF(child == nullptr, "Node::RemoveChildren NULL pointer exception.");
|
||||||
|
|
||||||
|
|
@ -726,7 +726,7 @@ bool e2d::Node::RemoveChild(Node * child)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::RemoveChildren(const String& child_name)
|
void easy2d::Node::RemoveChildren(const String& child_name)
|
||||||
{
|
{
|
||||||
if (children_.empty())
|
if (children_.empty())
|
||||||
{
|
{
|
||||||
|
|
@ -753,7 +753,7 @@ void e2d::Node::RemoveChildren(const String& child_name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::RemoveAllChildren()
|
void easy2d::Node::RemoveAllChildren()
|
||||||
{
|
{
|
||||||
// 所有节点的引用计数减一
|
// 所有节点的引用计数减一
|
||||||
for (const auto& child : children_)
|
for (const auto& child : children_)
|
||||||
|
|
@ -764,7 +764,7 @@ void e2d::Node::RemoveAllChildren()
|
||||||
children_.clear();
|
children_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::RunAction(Action * action)
|
void easy2d::Node::RunAction(Action * action)
|
||||||
{
|
{
|
||||||
WARN_IF(action == nullptr, "Action NULL pointer exception!");
|
WARN_IF(action == nullptr, "Action NULL pointer exception!");
|
||||||
|
|
||||||
|
|
@ -787,7 +787,7 @@ void e2d::Node::RunAction(Action * action)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::ResumeAction(const String& name)
|
void easy2d::Node::ResumeAction(const String& name)
|
||||||
{
|
{
|
||||||
if (actions_.empty())
|
if (actions_.empty())
|
||||||
return;
|
return;
|
||||||
|
|
@ -801,7 +801,7 @@ void e2d::Node::ResumeAction(const String& name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::PauseAction(const String& name)
|
void easy2d::Node::PauseAction(const String& name)
|
||||||
{
|
{
|
||||||
if (actions_.empty())
|
if (actions_.empty())
|
||||||
return;
|
return;
|
||||||
|
|
@ -815,7 +815,7 @@ void e2d::Node::PauseAction(const String& name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::StopAction(const String& name)
|
void easy2d::Node::StopAction(const String& name)
|
||||||
{
|
{
|
||||||
if (actions_.empty())
|
if (actions_.empty())
|
||||||
return;
|
return;
|
||||||
|
|
@ -829,7 +829,7 @@ void e2d::Node::StopAction(const String& name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Node::ContainsPoint(const Point& point)
|
bool easy2d::Node::ContainsPoint(const Point& point)
|
||||||
{
|
{
|
||||||
if (transform_.size.width == 0.f || transform_.size.height == 0.f)
|
if (transform_.size.width == 0.f || transform_.size.height == 0.f)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -847,7 +847,7 @@ bool e2d::Node::ContainsPoint(const Point& point)
|
||||||
return ret != 0;
|
return ret != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Node::Intersects(Node * node)
|
bool easy2d::Node::Intersects(Node * node)
|
||||||
{
|
{
|
||||||
if (transform_.size.width == 0.f || transform_.size.height == 0.f || node->transform_.size.width == 0.f || node->transform_.size.height == 0.f)
|
if (transform_.size.width == 0.f || transform_.size.height == 0.f || node->transform_.size.width == 0.f || node->transform_.size.height == 0.f)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -869,7 +869,7 @@ bool e2d::Node::Intersects(Node * node)
|
||||||
relation != D2D1_GEOMETRY_RELATION_DISJOINT;
|
relation != D2D1_GEOMETRY_RELATION_DISJOINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::ResumeAllActions()
|
void easy2d::Node::ResumeAllActions()
|
||||||
{
|
{
|
||||||
if (actions_.empty())
|
if (actions_.empty())
|
||||||
return;
|
return;
|
||||||
|
|
@ -880,7 +880,7 @@ void e2d::Node::ResumeAllActions()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::PauseAllActions()
|
void easy2d::Node::PauseAllActions()
|
||||||
{
|
{
|
||||||
if (actions_.empty())
|
if (actions_.empty())
|
||||||
return;
|
return;
|
||||||
|
|
@ -891,7 +891,7 @@ void e2d::Node::PauseAllActions()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::StopAllActions()
|
void easy2d::Node::StopAllActions()
|
||||||
{
|
{
|
||||||
if (actions_.empty())
|
if (actions_.empty())
|
||||||
return;
|
return;
|
||||||
|
|
@ -902,12 +902,12 @@ void e2d::Node::StopAllActions()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const e2d::Node::Actions & e2d::Node::GetAllActions() const
|
const easy2d::Node::Actions & easy2d::Node::GetAllActions() const
|
||||||
{
|
{
|
||||||
return actions_;
|
return actions_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::AddTask(Task * task)
|
void easy2d::Node::AddTask(Task * task)
|
||||||
{
|
{
|
||||||
if (task)
|
if (task)
|
||||||
{
|
{
|
||||||
|
|
@ -921,7 +921,7 @@ void e2d::Node::AddTask(Task * task)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::StopTasks(const String& name)
|
void easy2d::Node::StopTasks(const String& name)
|
||||||
{
|
{
|
||||||
for (const auto& task : tasks_)
|
for (const auto& task : tasks_)
|
||||||
{
|
{
|
||||||
|
|
@ -932,7 +932,7 @@ void e2d::Node::StopTasks(const String& name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::StartTasks(const String& name)
|
void easy2d::Node::StartTasks(const String& name)
|
||||||
{
|
{
|
||||||
for (const auto& task : tasks_)
|
for (const auto& task : tasks_)
|
||||||
{
|
{
|
||||||
|
|
@ -943,7 +943,7 @@ void e2d::Node::StartTasks(const String& name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::RemoveTasks(const String& name)
|
void easy2d::Node::RemoveTasks(const String& name)
|
||||||
{
|
{
|
||||||
for (const auto& task : tasks_)
|
for (const auto& task : tasks_)
|
||||||
{
|
{
|
||||||
|
|
@ -954,7 +954,7 @@ void e2d::Node::RemoveTasks(const String& name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::StopAllTasks()
|
void easy2d::Node::StopAllTasks()
|
||||||
{
|
{
|
||||||
for (const auto& task : tasks_)
|
for (const auto& task : tasks_)
|
||||||
{
|
{
|
||||||
|
|
@ -962,7 +962,7 @@ void e2d::Node::StopAllTasks()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::StartAllTasks()
|
void easy2d::Node::StartAllTasks()
|
||||||
{
|
{
|
||||||
for (const auto& task : tasks_)
|
for (const auto& task : tasks_)
|
||||||
{
|
{
|
||||||
|
|
@ -970,7 +970,7 @@ void e2d::Node::StartAllTasks()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::RemoveAllTasks()
|
void easy2d::Node::RemoveAllTasks()
|
||||||
{
|
{
|
||||||
for (const auto& task : tasks_)
|
for (const auto& task : tasks_)
|
||||||
{
|
{
|
||||||
|
|
@ -978,12 +978,12 @@ void e2d::Node::RemoveAllTasks()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const e2d::Node::Tasks & e2d::Node::GetAllTasks() const
|
const easy2d::Node::Tasks & easy2d::Node::GetAllTasks() const
|
||||||
{
|
{
|
||||||
return tasks_;
|
return tasks_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::UpdateTasks()
|
void easy2d::Node::UpdateTasks()
|
||||||
{
|
{
|
||||||
if (tasks_.empty())
|
if (tasks_.empty())
|
||||||
return;
|
return;
|
||||||
|
|
@ -1016,7 +1016,7 @@ void e2d::Node::UpdateTasks()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::UpdateTime()
|
void easy2d::Node::UpdateTime()
|
||||||
{
|
{
|
||||||
for (const auto& action : actions_)
|
for (const auto& action : actions_)
|
||||||
{
|
{
|
||||||
|
|
@ -1034,12 +1034,12 @@ void e2d::Node::UpdateTime()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::SetVisible(bool value)
|
void easy2d::Node::SetVisible(bool value)
|
||||||
{
|
{
|
||||||
visible_ = value;
|
visible_ = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::SetName(const String& name)
|
void easy2d::Node::SetName(const String& name)
|
||||||
{
|
{
|
||||||
WARN_IF(name.IsEmpty(), "Invalid Node name.");
|
WARN_IF(name.IsEmpty(), "Invalid Node name.");
|
||||||
|
|
||||||
|
|
@ -1052,7 +1052,7 @@ void e2d::Node::SetName(const String& name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::SetParentScene(Scene * scene)
|
void easy2d::Node::SetParentScene(Scene * scene)
|
||||||
{
|
{
|
||||||
parent_scene_ = scene;
|
parent_scene_ = scene;
|
||||||
for (const auto& child : children_)
|
for (const auto& child : children_)
|
||||||
|
|
|
||||||
|
|
@ -21,20 +21,20 @@
|
||||||
#include "..\e2dmodule.h"
|
#include "..\e2dmodule.h"
|
||||||
#include "..\e2dobject.h"
|
#include "..\e2dobject.h"
|
||||||
|
|
||||||
e2d::Scene::Scene()
|
easy2d::Scene::Scene()
|
||||||
: root_(nullptr)
|
: root_(nullptr)
|
||||||
, transform_(D2D1::Matrix3x2F::Identity())
|
, transform_(D2D1::Matrix3x2F::Identity())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Scene::Scene(Node * root)
|
easy2d::Scene::Scene(Node * root)
|
||||||
: root_(nullptr)
|
: root_(nullptr)
|
||||||
, transform_(D2D1::Matrix3x2F::Identity())
|
, transform_(D2D1::Matrix3x2F::Identity())
|
||||||
{
|
{
|
||||||
this->SetRoot(root);
|
this->SetRoot(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Scene::~Scene()
|
easy2d::Scene::~Scene()
|
||||||
{
|
{
|
||||||
if (root_)
|
if (root_)
|
||||||
{
|
{
|
||||||
|
|
@ -43,7 +43,7 @@ e2d::Scene::~Scene()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Scene::SetRoot(Node * root)
|
void easy2d::Scene::SetRoot(Node * root)
|
||||||
{
|
{
|
||||||
if (root_ == root)
|
if (root_ == root)
|
||||||
return;
|
return;
|
||||||
|
|
@ -63,12 +63,12 @@ void e2d::Scene::SetRoot(Node * root)
|
||||||
root_ = root;
|
root_ = root;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Node * e2d::Scene::GetRoot() const
|
easy2d::Node * easy2d::Scene::GetRoot() const
|
||||||
{
|
{
|
||||||
return root_;
|
return root_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Scene::Draw()
|
void easy2d::Scene::Draw()
|
||||||
{
|
{
|
||||||
if (root_)
|
if (root_)
|
||||||
{
|
{
|
||||||
|
|
@ -76,7 +76,7 @@ void e2d::Scene::Draw()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Scene::Dispatch(const MouseEvent & e)
|
void easy2d::Scene::Dispatch(const MouseEvent & e)
|
||||||
{
|
{
|
||||||
auto handler = dynamic_cast<MouseEventHandler*>(this);
|
auto handler = dynamic_cast<MouseEventHandler*>(this);
|
||||||
if (handler)
|
if (handler)
|
||||||
|
|
@ -90,7 +90,7 @@ void e2d::Scene::Dispatch(const MouseEvent & e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Scene::Dispatch(const KeyEvent & e)
|
void easy2d::Scene::Dispatch(const KeyEvent & e)
|
||||||
{
|
{
|
||||||
auto handler = dynamic_cast<KeyEventHandler*>(this);
|
auto handler = dynamic_cast<KeyEventHandler*>(this);
|
||||||
if (handler)
|
if (handler)
|
||||||
|
|
@ -104,7 +104,7 @@ void e2d::Scene::Dispatch(const KeyEvent & e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Scene::SetTransform(const D2D1::Matrix3x2F& matrix)
|
void easy2d::Scene::SetTransform(const D2D1::Matrix3x2F& matrix)
|
||||||
{
|
{
|
||||||
transform_ = matrix;
|
transform_ = matrix;
|
||||||
|
|
||||||
|
|
@ -114,7 +114,7 @@ void e2d::Scene::SetTransform(const D2D1::Matrix3x2F& matrix)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const D2D1::Matrix3x2F & e2d::Scene::GetTransform() const
|
const D2D1::Matrix3x2F & easy2d::Scene::GetTransform() const
|
||||||
{
|
{
|
||||||
return transform_;
|
return transform_;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,49 +21,49 @@
|
||||||
#include "..\e2dobject.h"
|
#include "..\e2dobject.h"
|
||||||
#include "..\e2dmodule.h"
|
#include "..\e2dmodule.h"
|
||||||
|
|
||||||
e2d::Sprite::Sprite()
|
easy2d::Sprite::Sprite()
|
||||||
: image_(nullptr)
|
: image_(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Sprite::Sprite(Image * image)
|
easy2d::Sprite::Sprite(Image * image)
|
||||||
: image_(nullptr)
|
: image_(nullptr)
|
||||||
{
|
{
|
||||||
Load(image);
|
Load(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Sprite::Sprite(const Resource& res)
|
easy2d::Sprite::Sprite(const Resource& res)
|
||||||
: image_(nullptr)
|
: image_(nullptr)
|
||||||
{
|
{
|
||||||
Load(res);
|
Load(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Sprite::Sprite(const Resource& res, const Rect& crop_rect)
|
easy2d::Sprite::Sprite(const Resource& res, const Rect& crop_rect)
|
||||||
: image_(nullptr)
|
: image_(nullptr)
|
||||||
{
|
{
|
||||||
Load(res);
|
Load(res);
|
||||||
Crop(crop_rect);
|
Crop(crop_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Sprite::Sprite(const String & file_name)
|
easy2d::Sprite::Sprite(const String & file_name)
|
||||||
: image_(nullptr)
|
: image_(nullptr)
|
||||||
{
|
{
|
||||||
Load(file_name);
|
Load(file_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Sprite::Sprite(const String & file_name, const Rect & crop_rect)
|
easy2d::Sprite::Sprite(const String & file_name, const Rect & crop_rect)
|
||||||
: image_(nullptr)
|
: image_(nullptr)
|
||||||
{
|
{
|
||||||
Load(file_name);
|
Load(file_name);
|
||||||
Crop(crop_rect);
|
Crop(crop_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Sprite::~Sprite()
|
easy2d::Sprite::~Sprite()
|
||||||
{
|
{
|
||||||
SafeRelease(image_);
|
SafeRelease(image_);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Sprite::Load(Image * image)
|
bool easy2d::Sprite::Load(Image * image)
|
||||||
{
|
{
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
|
|
@ -81,7 +81,7 @@ bool e2d::Sprite::Load(Image * image)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Sprite::Load(const Resource& res)
|
bool easy2d::Sprite::Load(const Resource& res)
|
||||||
{
|
{
|
||||||
if (!image_)
|
if (!image_)
|
||||||
{
|
{
|
||||||
|
|
@ -97,7 +97,7 @@ bool e2d::Sprite::Load(const Resource& res)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Sprite::Load(const String & file_name)
|
bool easy2d::Sprite::Load(const String & file_name)
|
||||||
{
|
{
|
||||||
if (!image_)
|
if (!image_)
|
||||||
{
|
{
|
||||||
|
|
@ -113,7 +113,7 @@ bool e2d::Sprite::Load(const String & file_name)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Sprite::Crop(const Rect& crop_rect)
|
void easy2d::Sprite::Crop(const Rect& crop_rect)
|
||||||
{
|
{
|
||||||
image_->Crop(crop_rect);
|
image_->Crop(crop_rect);
|
||||||
Node::SetSize(
|
Node::SetSize(
|
||||||
|
|
@ -122,12 +122,12 @@ void e2d::Sprite::Crop(const Rect& crop_rect)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Image * e2d::Sprite::GetImage() const
|
easy2d::Image * easy2d::Sprite::GetImage() const
|
||||||
{
|
{
|
||||||
return image_;
|
return image_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Sprite::Draw() const
|
void easy2d::Sprite::Draw() const
|
||||||
{
|
{
|
||||||
if (image_ && image_->GetBitmap())
|
if (image_ && image_->GetBitmap())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
#include "..\e2dobject.h"
|
#include "..\e2dobject.h"
|
||||||
|
|
||||||
|
|
||||||
e2d::Task::Task(const Function & func, const String & name)
|
easy2d::Task::Task(const Function & func, const String & name)
|
||||||
: running_(true)
|
: running_(true)
|
||||||
, stopped_(false)
|
, stopped_(false)
|
||||||
, run_times_(0)
|
, run_times_(0)
|
||||||
|
|
@ -32,7 +32,7 @@ e2d::Task::Task(const Function & func, const String & name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Task::Task(const Function & func, float delay, int times, const String & name)
|
easy2d::Task::Task(const Function & func, float delay, int times, const String & name)
|
||||||
: running_(true)
|
: running_(true)
|
||||||
, stopped_(false)
|
, stopped_(false)
|
||||||
, run_times_(0)
|
, run_times_(0)
|
||||||
|
|
@ -43,18 +43,18 @@ e2d::Task::Task(const Function & func, float delay, int times, const String & na
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Task::Start()
|
void easy2d::Task::Start()
|
||||||
{
|
{
|
||||||
running_ = true;
|
running_ = true;
|
||||||
last_time_ = Time::Now();
|
last_time_ = Time::Now();
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Task::Stop()
|
void easy2d::Task::Stop()
|
||||||
{
|
{
|
||||||
running_ = false;
|
running_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Task::Update()
|
void easy2d::Task::Update()
|
||||||
{
|
{
|
||||||
if (total_times_ == 0)
|
if (total_times_ == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -77,12 +77,12 @@ void e2d::Task::Update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Task::ResetTime()
|
void easy2d::Task::ResetTime()
|
||||||
{
|
{
|
||||||
last_time_ = Time::Now();
|
last_time_ = Time::Now();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Task::IsReady() const
|
bool easy2d::Task::IsReady() const
|
||||||
{
|
{
|
||||||
if (running_)
|
if (running_)
|
||||||
{
|
{
|
||||||
|
|
@ -98,12 +98,12 @@ bool e2d::Task::IsReady() const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Task::IsRunning() const
|
bool easy2d::Task::IsRunning() const
|
||||||
{
|
{
|
||||||
return running_;
|
return running_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const e2d::String& e2d::Task::GetName() const
|
const easy2d::String& easy2d::Task::GetName() const
|
||||||
{
|
{
|
||||||
return name_;
|
return name_;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
// Style
|
// Style
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
e2d::Text::Style::Style()
|
easy2d::Text::Style::Style()
|
||||||
: color(Color::White)
|
: color(Color::White)
|
||||||
, alignment(Align::Left)
|
, alignment(Align::Left)
|
||||||
, wrap(false)
|
, wrap(false)
|
||||||
|
|
@ -39,7 +39,7 @@ e2d::Text::Style::Style()
|
||||||
, outline_stroke(Stroke::Round)
|
, outline_stroke(Stroke::Round)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
e2d::Text::Style::Style(
|
easy2d::Text::Style::Style(
|
||||||
Color color,
|
Color color,
|
||||||
Align alignment,
|
Align alignment,
|
||||||
bool wrap,
|
bool wrap,
|
||||||
|
|
@ -71,7 +71,7 @@ e2d::Text::Style::Style(
|
||||||
// Text
|
// Text
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
e2d::Text::Text()
|
easy2d::Text::Text()
|
||||||
: font_()
|
: font_()
|
||||||
, style_()
|
, style_()
|
||||||
, text_layout_(nullptr)
|
, text_layout_(nullptr)
|
||||||
|
|
@ -79,7 +79,7 @@ e2d::Text::Text()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Text::Text(const String & text, const Font & font, const Style & style)
|
easy2d::Text::Text(const String & text, const Font & font, const Style & style)
|
||||||
: font_(font)
|
: font_(font)
|
||||||
, style_(style)
|
, style_(style)
|
||||||
, text_layout_(nullptr)
|
, text_layout_(nullptr)
|
||||||
|
|
@ -89,63 +89,63 @@ e2d::Text::Text(const String & text, const Font & font, const Style & style)
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Text::~Text()
|
easy2d::Text::~Text()
|
||||||
{
|
{
|
||||||
SafeRelease(text_format_);
|
SafeRelease(text_format_);
|
||||||
SafeRelease(text_layout_);
|
SafeRelease(text_layout_);
|
||||||
}
|
}
|
||||||
|
|
||||||
const e2d::String& e2d::Text::GetText() const
|
const easy2d::String& easy2d::Text::GetText() const
|
||||||
{
|
{
|
||||||
return text_;
|
return text_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const e2d::Font& e2d::Text::GetFont() const
|
const easy2d::Font& easy2d::Text::GetFont() const
|
||||||
{
|
{
|
||||||
return font_;
|
return font_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const e2d::Text::Style& e2d::Text::GetStyle() const
|
const easy2d::Text::Style& easy2d::Text::GetStyle() const
|
||||||
{
|
{
|
||||||
return style_;
|
return style_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const e2d::String& e2d::Text::GetFontFamily() const
|
const easy2d::String& easy2d::Text::GetFontFamily() const
|
||||||
{
|
{
|
||||||
return font_.family;
|
return font_.family;
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Text::GetFontSize() const
|
float easy2d::Text::GetFontSize() const
|
||||||
{
|
{
|
||||||
return font_.size;
|
return font_.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT e2d::Text::GetFontWeight() const
|
UINT easy2d::Text::GetFontWeight() const
|
||||||
{
|
{
|
||||||
return font_.weight;
|
return font_.weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
const e2d::Color& e2d::Text::GetColor() const
|
const easy2d::Color& easy2d::Text::GetColor() const
|
||||||
{
|
{
|
||||||
return style_.color;
|
return style_.color;
|
||||||
}
|
}
|
||||||
|
|
||||||
const e2d::Color& e2d::Text::GetOutlineColor() const
|
const easy2d::Color& easy2d::Text::GetOutlineColor() const
|
||||||
{
|
{
|
||||||
return style_.outline_color;
|
return style_.outline_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Text::GetOutlineWidth() const
|
float easy2d::Text::GetOutlineWidth() const
|
||||||
{
|
{
|
||||||
return style_.outline_width;
|
return style_.outline_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Stroke e2d::Text::GetOutlineStroke() const
|
easy2d::Stroke easy2d::Text::GetOutlineStroke() const
|
||||||
{
|
{
|
||||||
return style_.outline_stroke;
|
return style_.outline_stroke;
|
||||||
}
|
}
|
||||||
|
|
||||||
int e2d::Text::GetLineCount() const
|
int easy2d::Text::GetLineCount() const
|
||||||
{
|
{
|
||||||
if (text_layout_)
|
if (text_layout_)
|
||||||
{
|
{
|
||||||
|
|
@ -159,74 +159,74 @@ int e2d::Text::GetLineCount() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Text::IsItalic() const
|
bool easy2d::Text::IsItalic() const
|
||||||
{
|
{
|
||||||
return font_.italic;
|
return font_.italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Text::strikethrough() const
|
bool easy2d::Text::strikethrough() const
|
||||||
{
|
{
|
||||||
return style_.strikethrough;
|
return style_.strikethrough;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Text::underline() const
|
bool easy2d::Text::underline() const
|
||||||
{
|
{
|
||||||
return style_.underline;
|
return style_.underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Text::outline() const
|
bool easy2d::Text::outline() const
|
||||||
{
|
{
|
||||||
return style_.outline;
|
return style_.outline;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Text::SetText(const String& text)
|
void easy2d::Text::SetText(const String& text)
|
||||||
{
|
{
|
||||||
text_ = text;
|
text_ = text;
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Text::SetStyle(const Style& style)
|
void easy2d::Text::SetStyle(const Style& style)
|
||||||
{
|
{
|
||||||
style_ = style;
|
style_ = style;
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Text::SetFont(const Font & font)
|
void easy2d::Text::SetFont(const Font & font)
|
||||||
{
|
{
|
||||||
font_ = font;
|
font_ = font;
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Text::SetFontFamily(const String& family)
|
void easy2d::Text::SetFontFamily(const String& family)
|
||||||
{
|
{
|
||||||
font_.family = family;
|
font_.family = family;
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Text::SetFontSize(float size)
|
void easy2d::Text::SetFontSize(float size)
|
||||||
{
|
{
|
||||||
font_.size = size;
|
font_.size = size;
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Text::SetFontWeight(UINT weight)
|
void easy2d::Text::SetFontWeight(UINT weight)
|
||||||
{
|
{
|
||||||
font_.weight = weight;
|
font_.weight = weight;
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Text::SetColor(Color color)
|
void easy2d::Text::SetColor(Color color)
|
||||||
{
|
{
|
||||||
style_.color = color;
|
style_.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Text::SetItalic(bool value)
|
void easy2d::Text::SetItalic(bool value)
|
||||||
{
|
{
|
||||||
font_.italic = value;
|
font_.italic = value;
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Text::SetWrapEnabled(bool wrap)
|
void easy2d::Text::SetWrapEnabled(bool wrap)
|
||||||
{
|
{
|
||||||
if (style_.wrap != wrap)
|
if (style_.wrap != wrap)
|
||||||
{
|
{
|
||||||
|
|
@ -235,7 +235,7 @@ void e2d::Text::SetWrapEnabled(bool wrap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Text::SetWrapWidth(float wrap_width)
|
void easy2d::Text::SetWrapWidth(float wrap_width)
|
||||||
{
|
{
|
||||||
if (style_.wrap_width != wrap_width)
|
if (style_.wrap_width != wrap_width)
|
||||||
{
|
{
|
||||||
|
|
@ -248,7 +248,7 @@ void e2d::Text::SetWrapWidth(float wrap_width)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Text::SetLineSpacing(float line_spacing)
|
void easy2d::Text::SetLineSpacing(float line_spacing)
|
||||||
{
|
{
|
||||||
if (style_.line_spacing != line_spacing)
|
if (style_.line_spacing != line_spacing)
|
||||||
{
|
{
|
||||||
|
|
@ -257,7 +257,7 @@ void e2d::Text::SetLineSpacing(float line_spacing)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Text::SetAlignment(Align align)
|
void easy2d::Text::SetAlignment(Align align)
|
||||||
{
|
{
|
||||||
if (style_.alignment != align)
|
if (style_.alignment != align)
|
||||||
{
|
{
|
||||||
|
|
@ -266,7 +266,7 @@ void e2d::Text::SetAlignment(Align align)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Text::SetUnderline(bool underline)
|
void easy2d::Text::SetUnderline(bool underline)
|
||||||
{
|
{
|
||||||
if (style_.underline != underline)
|
if (style_.underline != underline)
|
||||||
{
|
{
|
||||||
|
|
@ -277,7 +277,7 @@ void e2d::Text::SetUnderline(bool underline)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Text::SetStrikethrough(bool strikethrough)
|
void easy2d::Text::SetStrikethrough(bool strikethrough)
|
||||||
{
|
{
|
||||||
if (style_.strikethrough != strikethrough)
|
if (style_.strikethrough != strikethrough)
|
||||||
{
|
{
|
||||||
|
|
@ -288,27 +288,27 @@ void e2d::Text::SetStrikethrough(bool strikethrough)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Text::SetOutline(bool outline)
|
void easy2d::Text::SetOutline(bool outline)
|
||||||
{
|
{
|
||||||
style_.outline = outline;
|
style_.outline = outline;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Text::SetOutlineColor(Color outline_color)
|
void easy2d::Text::SetOutlineColor(Color outline_color)
|
||||||
{
|
{
|
||||||
style_.outline_color = outline_color;
|
style_.outline_color = outline_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Text::SetOutlineWidth(float outline_width)
|
void easy2d::Text::SetOutlineWidth(float outline_width)
|
||||||
{
|
{
|
||||||
style_.outline_width = outline_width;
|
style_.outline_width = outline_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Text::SetOutlineStroke(Stroke outline_stroke)
|
void easy2d::Text::SetOutlineStroke(Stroke outline_stroke)
|
||||||
{
|
{
|
||||||
style_.outline_stroke = outline_stroke;
|
style_.outline_stroke = outline_stroke;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Text::Draw() const
|
void easy2d::Text::Draw() const
|
||||||
{
|
{
|
||||||
if (text_layout_)
|
if (text_layout_)
|
||||||
{
|
{
|
||||||
|
|
@ -330,7 +330,7 @@ void e2d::Text::Draw() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Text::Reset()
|
void easy2d::Text::Reset()
|
||||||
{
|
{
|
||||||
// ´´½¨ÎÄ×Ö¸ñʽ»¯
|
// ´´½¨ÎÄ×Ö¸ñʽ»¯
|
||||||
CreateFormat();
|
CreateFormat();
|
||||||
|
|
@ -338,7 +338,7 @@ void e2d::Text::Reset()
|
||||||
CreateLayout();
|
CreateLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Text::CreateFormat()
|
void easy2d::Text::CreateFormat()
|
||||||
{
|
{
|
||||||
SafeRelease(text_format_);
|
SafeRelease(text_format_);
|
||||||
|
|
||||||
|
|
@ -383,7 +383,7 @@ void e2d::Text::CreateFormat()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Text::CreateLayout()
|
void easy2d::Text::CreateLayout()
|
||||||
{
|
{
|
||||||
SafeRelease(text_layout_);
|
SafeRelease(text_layout_);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,14 +21,14 @@
|
||||||
#include "..\e2dtool.h"
|
#include "..\e2dtool.h"
|
||||||
|
|
||||||
|
|
||||||
e2d::Data::Data(const String & key, const String & field)
|
easy2d::Data::Data(const String & key, const String & field)
|
||||||
: key_(key)
|
: key_(key)
|
||||||
, field_(field)
|
, field_(field)
|
||||||
, data_path_(Path::GetDataPath())
|
, data_path_(Path::GetDataPath())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Data::Exists() const
|
bool easy2d::Data::Exists() const
|
||||||
{
|
{
|
||||||
wchar_t temp[256] = { 0 };
|
wchar_t temp[256] = { 0 };
|
||||||
::GetPrivateProfileStringW(
|
::GetPrivateProfileStringW(
|
||||||
|
|
@ -42,7 +42,7 @@ bool e2d::Data::Exists() const
|
||||||
return temp[0] == L'\0';
|
return temp[0] == L'\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Data::SaveInt(int value)
|
bool easy2d::Data::SaveInt(int value)
|
||||||
{
|
{
|
||||||
BOOL ret = ::WritePrivateProfileStringW(
|
BOOL ret = ::WritePrivateProfileStringW(
|
||||||
(LPCWSTR)field_,
|
(LPCWSTR)field_,
|
||||||
|
|
@ -53,7 +53,7 @@ bool e2d::Data::SaveInt(int value)
|
||||||
return ret != 0;
|
return ret != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Data::SaveFloat(float value)
|
bool easy2d::Data::SaveFloat(float value)
|
||||||
{
|
{
|
||||||
BOOL ret = ::WritePrivateProfileStringW(
|
BOOL ret = ::WritePrivateProfileStringW(
|
||||||
(LPCWSTR)field_,
|
(LPCWSTR)field_,
|
||||||
|
|
@ -64,7 +64,7 @@ bool e2d::Data::SaveFloat(float value)
|
||||||
return ret != 0;
|
return ret != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Data::SaveDouble(double value)
|
bool easy2d::Data::SaveDouble(double value)
|
||||||
{
|
{
|
||||||
BOOL ret = ::WritePrivateProfileStringW(
|
BOOL ret = ::WritePrivateProfileStringW(
|
||||||
(LPCWSTR)field_,
|
(LPCWSTR)field_,
|
||||||
|
|
@ -75,7 +75,7 @@ bool e2d::Data::SaveDouble(double value)
|
||||||
return ret != 0;
|
return ret != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Data::SaveBool(bool value)
|
bool easy2d::Data::SaveBool(bool value)
|
||||||
{
|
{
|
||||||
BOOL ret = ::WritePrivateProfileStringW(
|
BOOL ret = ::WritePrivateProfileStringW(
|
||||||
(LPCWSTR)field_,
|
(LPCWSTR)field_,
|
||||||
|
|
@ -86,7 +86,7 @@ bool e2d::Data::SaveBool(bool value)
|
||||||
return ret != 0;
|
return ret != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Data::SaveString(const String& value)
|
bool easy2d::Data::SaveString(const String& value)
|
||||||
{
|
{
|
||||||
BOOL ret = ::WritePrivateProfileStringW(
|
BOOL ret = ::WritePrivateProfileStringW(
|
||||||
(LPCWSTR)field_,
|
(LPCWSTR)field_,
|
||||||
|
|
@ -97,7 +97,7 @@ bool e2d::Data::SaveString(const String& value)
|
||||||
return ret != 0;
|
return ret != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int e2d::Data::GetInt() const
|
int easy2d::Data::GetInt() const
|
||||||
{
|
{
|
||||||
return ::GetPrivateProfileIntW(
|
return ::GetPrivateProfileIntW(
|
||||||
(LPCWSTR)field_,
|
(LPCWSTR)field_,
|
||||||
|
|
@ -107,21 +107,21 @@ int e2d::Data::GetInt() const
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Data::GetFloat() const
|
float easy2d::Data::GetFloat() const
|
||||||
{
|
{
|
||||||
wchar_t temp[32] = { 0 };
|
wchar_t temp[32] = { 0 };
|
||||||
::GetPrivateProfileStringW((LPCWSTR)field_, (LPCWSTR)key_, L"0.0", temp, 31, (LPCWSTR)data_path_);
|
::GetPrivateProfileStringW((LPCWSTR)field_, (LPCWSTR)key_, L"0.0", temp, 31, (LPCWSTR)data_path_);
|
||||||
return std::stof(temp);
|
return std::stof(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
double e2d::Data::GetDouble() const
|
double easy2d::Data::GetDouble() const
|
||||||
{
|
{
|
||||||
wchar_t temp[32] = { 0 };
|
wchar_t temp[32] = { 0 };
|
||||||
::GetPrivateProfileStringW((LPCWSTR)field_, (LPCWSTR)key_, L"0.0", temp, 31, (LPCWSTR)data_path_);
|
::GetPrivateProfileStringW((LPCWSTR)field_, (LPCWSTR)key_, L"0.0", temp, 31, (LPCWSTR)data_path_);
|
||||||
return std::stod(temp);
|
return std::stod(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Data::GetBool() const
|
bool easy2d::Data::GetBool() const
|
||||||
{
|
{
|
||||||
int nValue = ::GetPrivateProfileIntW(
|
int nValue = ::GetPrivateProfileIntW(
|
||||||
(LPCWSTR)field_,
|
(LPCWSTR)field_,
|
||||||
|
|
@ -131,7 +131,7 @@ bool e2d::Data::GetBool() const
|
||||||
return nValue != 0;
|
return nValue != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String e2d::Data::GetString()
|
easy2d::String easy2d::Data::GetString()
|
||||||
{
|
{
|
||||||
wchar_t temp[256] = { 0 };
|
wchar_t temp[256] = { 0 };
|
||||||
::GetPrivateProfileStringW(
|
::GetPrivateProfileStringW(
|
||||||
|
|
|
||||||
|
|
@ -22,26 +22,26 @@
|
||||||
#include "..\e2dmodule.h"
|
#include "..\e2dmodule.h"
|
||||||
#include <shobjidl.h>
|
#include <shobjidl.h>
|
||||||
|
|
||||||
std::list<e2d::String> e2d::File::search_paths_;
|
std::list<easy2d::String> easy2d::File::search_paths_;
|
||||||
|
|
||||||
e2d::File::File()
|
easy2d::File::File()
|
||||||
: file_path_()
|
: file_path_()
|
||||||
, attributes_(0)
|
, attributes_(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::File::File(const String & file_name)
|
easy2d::File::File(const String & file_name)
|
||||||
: file_path_(file_name)
|
: file_path_(file_name)
|
||||||
, attributes_(0)
|
, attributes_(0)
|
||||||
{
|
{
|
||||||
this->Open(file_name);
|
this->Open(file_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::File::~File()
|
easy2d::File::~File()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::File::Open(const String & file_name)
|
bool easy2d::File::Open(const String & file_name)
|
||||||
{
|
{
|
||||||
if (file_name.IsEmpty())
|
if (file_name.IsEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -75,22 +75,22 @@ bool e2d::File::Open(const String & file_name)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::File::Exists() const
|
bool easy2d::File::Exists() const
|
||||||
{
|
{
|
||||||
return ::_waccess((const wchar_t*)file_path_, 0) == 0;
|
return ::_waccess((const wchar_t*)file_path_, 0) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::File::IsFolder() const
|
bool easy2d::File::IsFolder() const
|
||||||
{
|
{
|
||||||
return (attributes_ & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
return (attributes_ & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const e2d::String& e2d::File::GetPath() const
|
const easy2d::String& easy2d::File::GetPath() const
|
||||||
{
|
{
|
||||||
return file_path_;
|
return file_path_;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String e2d::File::GetExtension() const
|
easy2d::String easy2d::File::GetExtension() const
|
||||||
{
|
{
|
||||||
String file_ext;
|
String file_ext;
|
||||||
// 找到文件名中的最后一个 '.' 的位置
|
// 找到文件名中的最后一个 '.' 的位置
|
||||||
|
|
@ -106,14 +106,14 @@ e2d::String e2d::File::GetExtension() const
|
||||||
return std::move(file_ext);
|
return std::move(file_ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::File::Delete()
|
bool easy2d::File::Delete()
|
||||||
{
|
{
|
||||||
if (::DeleteFile((LPCWSTR)file_path_))
|
if (::DeleteFile((LPCWSTR)file_path_))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::File e2d::File::Extract(int resource_name, const String & resource_type, const String& dest_file_name)
|
easy2d::File easy2d::File::Extract(int resource_name, const String & resource_type, const String& dest_file_name)
|
||||||
{
|
{
|
||||||
// 创建文件
|
// 创建文件
|
||||||
HANDLE file = ::CreateFile(
|
HANDLE file = ::CreateFile(
|
||||||
|
|
@ -150,7 +150,7 @@ e2d::File e2d::File::Extract(int resource_name, const String & resource_type, co
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::File::AddSearchPath(const String & path)
|
void easy2d::File::AddSearchPath(const String & path)
|
||||||
{
|
{
|
||||||
String tmp = path;
|
String tmp = path;
|
||||||
tmp.Replace(L"/", L"\\");
|
tmp.Replace(L"/", L"\\");
|
||||||
|
|
@ -165,7 +165,7 @@ void e2d::File::AddSearchPath(const String & path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::File::CreateFolder(const String & dir_path)
|
bool easy2d::File::CreateFolder(const String & dir_path)
|
||||||
{
|
{
|
||||||
if (dir_path.IsEmpty() || dir_path.GetLength() >= MAX_PATH)
|
if (dir_path.IsEmpty() || dir_path.GetLength() >= MAX_PATH)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -190,7 +190,7 @@ bool e2d::File::CreateFolder(const String & dir_path)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::File e2d::File::ShowOpenDialog(const String & title, const String & filter)
|
easy2d::File easy2d::File::ShowOpenDialog(const String & title, const String & filter)
|
||||||
{
|
{
|
||||||
String file_path;
|
String file_path;
|
||||||
HRESULT hr = ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
|
HRESULT hr = ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
|
||||||
|
|
@ -252,7 +252,7 @@ e2d::File e2d::File::ShowOpenDialog(const String & title, const String & filter)
|
||||||
return std::move(File(file_path));
|
return std::move(File(file_path));
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::File e2d::File::ShowSaveDialog(const String & title, const String& def_file, const String & def_ext)
|
easy2d::File easy2d::File::ShowSaveDialog(const String & title, const String& def_file, const String & def_ext)
|
||||||
{
|
{
|
||||||
String file_path;
|
String file_path;
|
||||||
HRESULT hr = ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
|
HRESULT hr = ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ inline bool TraceError(wchar_t* prompt, HRESULT hr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace e2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
|
|
||||||
class Transcoder
|
class Transcoder
|
||||||
|
|
@ -315,7 +315,7 @@ namespace e2d
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
e2d::Music::Music()
|
easy2d::Music::Music()
|
||||||
: opened_(false)
|
: opened_(false)
|
||||||
, playing_(false)
|
, playing_(false)
|
||||||
, wave_data_(nullptr)
|
, wave_data_(nullptr)
|
||||||
|
|
@ -324,12 +324,12 @@ e2d::Music::Music()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Music::~Music()
|
easy2d::Music::~Music()
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Music::Load(const e2d::String & file_path)
|
bool easy2d::Music::Load(const easy2d::String & file_path)
|
||||||
{
|
{
|
||||||
if (opened_)
|
if (opened_)
|
||||||
{
|
{
|
||||||
|
|
@ -368,7 +368,7 @@ bool e2d::Music::Load(const e2d::String & file_path)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Music::Load(const Resource& res)
|
bool easy2d::Music::Load(const Resource& res)
|
||||||
{
|
{
|
||||||
if (opened_)
|
if (opened_)
|
||||||
{
|
{
|
||||||
|
|
@ -396,7 +396,7 @@ bool e2d::Music::Load(const Resource& res)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Music::Play(int loop_count)
|
bool easy2d::Music::Play(int loop_count)
|
||||||
{
|
{
|
||||||
if (!opened_)
|
if (!opened_)
|
||||||
{
|
{
|
||||||
|
|
@ -446,7 +446,7 @@ bool e2d::Music::Play(int loop_count)
|
||||||
return playing_;
|
return playing_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Music::Pause()
|
void easy2d::Music::Pause()
|
||||||
{
|
{
|
||||||
if (voice_)
|
if (voice_)
|
||||||
{
|
{
|
||||||
|
|
@ -457,7 +457,7 @@ void e2d::Music::Pause()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Music::Resume()
|
void easy2d::Music::Resume()
|
||||||
{
|
{
|
||||||
if (voice_)
|
if (voice_)
|
||||||
{
|
{
|
||||||
|
|
@ -468,7 +468,7 @@ void e2d::Music::Resume()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Music::Stop()
|
void easy2d::Music::Stop()
|
||||||
{
|
{
|
||||||
if (voice_)
|
if (voice_)
|
||||||
{
|
{
|
||||||
|
|
@ -481,7 +481,7 @@ void e2d::Music::Stop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Music::Close()
|
void easy2d::Music::Close()
|
||||||
{
|
{
|
||||||
if (voice_)
|
if (voice_)
|
||||||
{
|
{
|
||||||
|
|
@ -501,7 +501,7 @@ void e2d::Music::Close()
|
||||||
playing_ = false;
|
playing_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Music::IsPlaying() const
|
bool easy2d::Music::IsPlaying() const
|
||||||
{
|
{
|
||||||
if (opened_ && voice_)
|
if (opened_ && voice_)
|
||||||
{
|
{
|
||||||
|
|
@ -513,7 +513,7 @@ bool e2d::Music::IsPlaying() const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Music::GetVolume() const
|
float easy2d::Music::GetVolume() const
|
||||||
{
|
{
|
||||||
if (voice_)
|
if (voice_)
|
||||||
{
|
{
|
||||||
|
|
@ -524,7 +524,7 @@ float e2d::Music::GetVolume() const
|
||||||
return 0.f;
|
return 0.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Music::SetVolume(float volume)
|
bool easy2d::Music::SetVolume(float volume)
|
||||||
{
|
{
|
||||||
if (voice_)
|
if (voice_)
|
||||||
{
|
{
|
||||||
|
|
@ -534,7 +534,7 @@ bool e2d::Music::SetVolume(float volume)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
IXAudio2SourceVoice * e2d::Music::GetSourceVoice() const
|
IXAudio2SourceVoice * easy2d::Music::GetSourceVoice() const
|
||||||
{
|
{
|
||||||
return voice_;
|
return voice_;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
#include "..\e2dmodule.h"
|
#include "..\e2dmodule.h"
|
||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
|
|
||||||
const e2d::String& e2d::Path::GetDataPath()
|
const easy2d::String& easy2d::Path::GetDataPath()
|
||||||
{
|
{
|
||||||
static String data_path;
|
static String data_path;
|
||||||
if (data_path.IsEmpty())
|
if (data_path.IsEmpty())
|
||||||
|
|
@ -47,7 +47,7 @@ const e2d::String& e2d::Path::GetDataPath()
|
||||||
return data_path;
|
return data_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
const e2d::String& e2d::Path::GetTemporaryPath()
|
const easy2d::String& easy2d::Path::GetTemporaryPath()
|
||||||
{
|
{
|
||||||
static String temp_path;
|
static String temp_path;
|
||||||
if (temp_path.IsEmpty())
|
if (temp_path.IsEmpty())
|
||||||
|
|
@ -71,7 +71,7 @@ const e2d::String& e2d::Path::GetTemporaryPath()
|
||||||
return temp_path;
|
return temp_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
const e2d::String& e2d::Path::GetLocalAppDataPath()
|
const easy2d::String& easy2d::Path::GetLocalAppDataPath()
|
||||||
{
|
{
|
||||||
static String local_app_data_path;
|
static String local_app_data_path;
|
||||||
if (local_app_data_path.IsEmpty())
|
if (local_app_data_path.IsEmpty())
|
||||||
|
|
@ -85,7 +85,7 @@ const e2d::String& e2d::Path::GetLocalAppDataPath()
|
||||||
return local_app_data_path;
|
return local_app_data_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
const e2d::String& e2d::Path::GetExeFilePath()
|
const easy2d::String& easy2d::Path::GetExeFilePath()
|
||||||
{
|
{
|
||||||
static String exe_file_path;
|
static String exe_file_path;
|
||||||
if (exe_file_path.IsEmpty())
|
if (exe_file_path.IsEmpty())
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,18 @@
|
||||||
#include "..\e2dtool.h"
|
#include "..\e2dtool.h"
|
||||||
|
|
||||||
|
|
||||||
std::map<size_t, e2d::Music*> e2d::Player::musics_;
|
std::map<size_t, easy2d::Music*> easy2d::Player::musics_;
|
||||||
|
|
||||||
e2d::Player::Player()
|
easy2d::Player::Player()
|
||||||
: volume_(1.f)
|
: volume_(1.f)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Player::~Player()
|
easy2d::Player::~Player()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Player::Load(const String & file_path)
|
bool easy2d::Player::Load(const String & file_path)
|
||||||
{
|
{
|
||||||
if (file_path.IsEmpty())
|
if (file_path.IsEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -35,7 +35,7 @@ bool e2d::Player::Load(const String & file_path)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Player::Play(const String & file_path, int loop_count)
|
bool easy2d::Player::Play(const String & file_path, int loop_count)
|
||||||
{
|
{
|
||||||
if (file_path.IsEmpty())
|
if (file_path.IsEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -51,7 +51,7 @@ bool e2d::Player::Play(const String & file_path, int loop_count)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Player::Pause(const String & file_path)
|
void easy2d::Player::Pause(const String & file_path)
|
||||||
{
|
{
|
||||||
if (file_path.IsEmpty())
|
if (file_path.IsEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
@ -61,7 +61,7 @@ void e2d::Player::Pause(const String & file_path)
|
||||||
musics_[hash]->Pause();
|
musics_[hash]->Pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Player::Resume(const String & file_path)
|
void easy2d::Player::Resume(const String & file_path)
|
||||||
{
|
{
|
||||||
if (file_path.IsEmpty())
|
if (file_path.IsEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
@ -71,7 +71,7 @@ void e2d::Player::Resume(const String & file_path)
|
||||||
musics_[hash]->Resume();
|
musics_[hash]->Resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Player::Stop(const String & file_path)
|
void easy2d::Player::Stop(const String & file_path)
|
||||||
{
|
{
|
||||||
if (file_path.IsEmpty())
|
if (file_path.IsEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
@ -81,7 +81,7 @@ void e2d::Player::Stop(const String & file_path)
|
||||||
musics_[hash]->Stop();
|
musics_[hash]->Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Player::IsPlaying(const String & file_path)
|
bool easy2d::Player::IsPlaying(const String & file_path)
|
||||||
{
|
{
|
||||||
if (file_path.IsEmpty())
|
if (file_path.IsEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -92,7 +92,7 @@ bool e2d::Player::IsPlaying(const String & file_path)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Player::Load(const Resource& res)
|
bool easy2d::Player::Load(const Resource& res)
|
||||||
{
|
{
|
||||||
if (musics_.end() != musics_.find(res.id))
|
if (musics_.end() != musics_.find(res.id))
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -115,7 +115,7 @@ bool e2d::Player::Load(const Resource& res)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Player::Play(const Resource& res, int loop_count)
|
bool easy2d::Player::Play(const Resource& res, int loop_count)
|
||||||
{
|
{
|
||||||
if (Load(res))
|
if (Load(res))
|
||||||
{
|
{
|
||||||
|
|
@ -128,37 +128,37 @@ bool e2d::Player::Play(const Resource& res, int loop_count)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Player::Pause(const Resource& res)
|
void easy2d::Player::Pause(const Resource& res)
|
||||||
{
|
{
|
||||||
if (musics_.end() != musics_.find(res.id))
|
if (musics_.end() != musics_.find(res.id))
|
||||||
musics_[res.id]->Pause();
|
musics_[res.id]->Pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Player::Resume(const Resource& res)
|
void easy2d::Player::Resume(const Resource& res)
|
||||||
{
|
{
|
||||||
if (musics_.end() != musics_.find(res.id))
|
if (musics_.end() != musics_.find(res.id))
|
||||||
musics_[res.id]->Resume();
|
musics_[res.id]->Resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Player::Stop(const Resource& res)
|
void easy2d::Player::Stop(const Resource& res)
|
||||||
{
|
{
|
||||||
if (musics_.end() != musics_.find(res.id))
|
if (musics_.end() != musics_.find(res.id))
|
||||||
musics_[res.id]->Stop();
|
musics_[res.id]->Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Player::IsPlaying(const Resource& res)
|
bool easy2d::Player::IsPlaying(const Resource& res)
|
||||||
{
|
{
|
||||||
if (musics_.end() != musics_.find(res.id))
|
if (musics_.end() != musics_.find(res.id))
|
||||||
return musics_[res.id]->IsPlaying();
|
return musics_[res.id]->IsPlaying();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Player::GetVolume() const
|
float easy2d::Player::GetVolume() const
|
||||||
{
|
{
|
||||||
return volume_;
|
return volume_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Player::SetVolume(float volume)
|
void easy2d::Player::SetVolume(float volume)
|
||||||
{
|
{
|
||||||
volume_ = std::min(std::max(volume, -224.f), 224.f);
|
volume_ = std::min(std::max(volume, -224.f), 224.f);
|
||||||
for (const auto& pair : musics_)
|
for (const auto& pair : musics_)
|
||||||
|
|
@ -167,7 +167,7 @@ void e2d::Player::SetVolume(float volume)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Player::PauseAll()
|
void easy2d::Player::PauseAll()
|
||||||
{
|
{
|
||||||
for (const auto& pair : musics_)
|
for (const auto& pair : musics_)
|
||||||
{
|
{
|
||||||
|
|
@ -175,7 +175,7 @@ void e2d::Player::PauseAll()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Player::ResumeAll()
|
void easy2d::Player::ResumeAll()
|
||||||
{
|
{
|
||||||
for (const auto& pair : musics_)
|
for (const auto& pair : musics_)
|
||||||
{
|
{
|
||||||
|
|
@ -183,7 +183,7 @@ void e2d::Player::ResumeAll()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Player::StopAll()
|
void easy2d::Player::StopAll()
|
||||||
{
|
{
|
||||||
for (const auto& pair : musics_)
|
for (const auto& pair : musics_)
|
||||||
{
|
{
|
||||||
|
|
@ -191,7 +191,7 @@ void e2d::Player::StopAll()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Player::ClearCache()
|
void easy2d::Player::ClearCache()
|
||||||
{
|
{
|
||||||
if (musics_.empty())
|
if (musics_.empty())
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#include "..\e2dtool.h"
|
#include "..\e2dtool.h"
|
||||||
|
|
||||||
std::default_random_engine &e2d::Random::GetEngine()
|
std::default_random_engine &easy2d::Random::GetEngine()
|
||||||
{
|
{
|
||||||
static std::random_device device;
|
static std::random_device device;
|
||||||
static std::default_random_engine engine(device());
|
static std::default_random_engine engine(device());
|
||||||
|
|
|
||||||
|
|
@ -21,19 +21,19 @@
|
||||||
#include "..\e2dtransition.h"
|
#include "..\e2dtransition.h"
|
||||||
#include "..\e2dobject.h"
|
#include "..\e2dobject.h"
|
||||||
|
|
||||||
e2d::BoxTransition::BoxTransition(float duration)
|
easy2d::BoxTransition::BoxTransition(float duration)
|
||||||
: Transition(duration)
|
: Transition(duration)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::BoxTransition::Init(Scene * prev, Scene * next, Game * game)
|
void easy2d::BoxTransition::Init(Scene * prev, Scene * next, Game * game)
|
||||||
{
|
{
|
||||||
Transition::Init(prev, next, game);
|
Transition::Init(prev, next, game);
|
||||||
|
|
||||||
in_layer_param_.opacity = 0;
|
in_layer_param_.opacity = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::BoxTransition::Update()
|
void easy2d::BoxTransition::Update()
|
||||||
{
|
{
|
||||||
Transition::Update();
|
Transition::Update();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,12 @@
|
||||||
#include "..\e2dtransition.h"
|
#include "..\e2dtransition.h"
|
||||||
#include "..\e2dobject.h"
|
#include "..\e2dobject.h"
|
||||||
|
|
||||||
e2d::EmergeTransition::EmergeTransition(float duration)
|
easy2d::EmergeTransition::EmergeTransition(float duration)
|
||||||
: Transition(duration)
|
: Transition(duration)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::EmergeTransition::Init(Scene * prev, Scene * next, Game * game)
|
void easy2d::EmergeTransition::Init(Scene * prev, Scene * next, Game * game)
|
||||||
{
|
{
|
||||||
Transition::Init(prev, next, game);
|
Transition::Init(prev, next, game);
|
||||||
|
|
||||||
|
|
@ -34,7 +34,7 @@ void e2d::EmergeTransition::Init(Scene * prev, Scene * next, Game * game)
|
||||||
in_layer_param_.opacity = 0;
|
in_layer_param_.opacity = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::EmergeTransition::Update()
|
void easy2d::EmergeTransition::Update()
|
||||||
{
|
{
|
||||||
Transition::Update();
|
Transition::Update();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,12 @@
|
||||||
#include "..\e2dtransition.h"
|
#include "..\e2dtransition.h"
|
||||||
#include "..\e2dobject.h"
|
#include "..\e2dobject.h"
|
||||||
|
|
||||||
e2d::FadeTransition::FadeTransition(float duration)
|
easy2d::FadeTransition::FadeTransition(float duration)
|
||||||
: Transition(duration)
|
: Transition(duration)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::FadeTransition::Init(Scene * prev, Scene * next, Game * game)
|
void easy2d::FadeTransition::Init(Scene * prev, Scene * next, Game * game)
|
||||||
{
|
{
|
||||||
Transition::Init(prev, next, game);
|
Transition::Init(prev, next, game);
|
||||||
|
|
||||||
|
|
@ -34,7 +34,7 @@ void e2d::FadeTransition::Init(Scene * prev, Scene * next, Game * game)
|
||||||
in_layer_param_.opacity = 0;
|
in_layer_param_.opacity = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::FadeTransition::Update()
|
void easy2d::FadeTransition::Update()
|
||||||
{
|
{
|
||||||
Transition::Update();
|
Transition::Update();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,13 @@
|
||||||
#include "..\e2dtransition.h"
|
#include "..\e2dtransition.h"
|
||||||
#include "..\e2dobject.h"
|
#include "..\e2dobject.h"
|
||||||
|
|
||||||
e2d::MoveTransition::MoveTransition(float duration, Direction direction)
|
easy2d::MoveTransition::MoveTransition(float duration, Direction direction)
|
||||||
: Transition(duration)
|
: Transition(duration)
|
||||||
, direction_(direction)
|
, direction_(direction)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::MoveTransition::Init(Scene * prev, Scene * next, Game * game)
|
void easy2d::MoveTransition::Init(Scene * prev, Scene * next, Game * game)
|
||||||
{
|
{
|
||||||
Transition::Init(prev, next, game);
|
Transition::Init(prev, next, game);
|
||||||
|
|
||||||
|
|
@ -67,7 +67,7 @@ void e2d::MoveTransition::Init(Scene * prev, Scene * next, Game * game)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::MoveTransition::Update()
|
void easy2d::MoveTransition::Update()
|
||||||
{
|
{
|
||||||
Transition::Update();
|
Transition::Update();
|
||||||
|
|
||||||
|
|
@ -94,7 +94,7 @@ void e2d::MoveTransition::Update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::MoveTransition::Reset()
|
void easy2d::MoveTransition::Reset()
|
||||||
{
|
{
|
||||||
if (out_scene_)
|
if (out_scene_)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,13 @@
|
||||||
#include "..\e2dtransition.h"
|
#include "..\e2dtransition.h"
|
||||||
#include "..\e2dobject.h"
|
#include "..\e2dobject.h"
|
||||||
|
|
||||||
e2d::RotationTransition::RotationTransition(float duration, float rotation)
|
easy2d::RotationTransition::RotationTransition(float duration, float rotation)
|
||||||
: Transition(duration)
|
: Transition(duration)
|
||||||
, rotation_(rotation)
|
, rotation_(rotation)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::RotationTransition::Init(Scene * prev, Scene * next, Game * game)
|
void easy2d::RotationTransition::Init(Scene * prev, Scene * next, Game * game)
|
||||||
{
|
{
|
||||||
Transition::Init(prev, next, game);
|
Transition::Init(prev, next, game);
|
||||||
|
|
||||||
|
|
@ -44,7 +44,7 @@ void e2d::RotationTransition::Init(Scene * prev, Scene * next, Game * game)
|
||||||
in_layer_param_.opacity = 0;
|
in_layer_param_.opacity = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::RotationTransition::Update()
|
void easy2d::RotationTransition::Update()
|
||||||
{
|
{
|
||||||
Transition::Update();
|
Transition::Update();
|
||||||
|
|
||||||
|
|
@ -90,7 +90,7 @@ void e2d::RotationTransition::Update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::RotationTransition::Reset()
|
void easy2d::RotationTransition::Reset()
|
||||||
{
|
{
|
||||||
if (out_scene_)
|
if (out_scene_)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
#include "..\e2dobject.h"
|
#include "..\e2dobject.h"
|
||||||
#include "..\e2dmodule.h"
|
#include "..\e2dmodule.h"
|
||||||
|
|
||||||
e2d::Transition::Transition(float duration)
|
easy2d::Transition::Transition(float duration)
|
||||||
: done_(false)
|
: done_(false)
|
||||||
, started_()
|
, started_()
|
||||||
, process_(0)
|
, process_(0)
|
||||||
|
|
@ -37,7 +37,7 @@ e2d::Transition::Transition(float duration)
|
||||||
duration_ = std::max(duration, 0.f);
|
duration_ = std::max(duration, 0.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Transition::~Transition()
|
easy2d::Transition::~Transition()
|
||||||
{
|
{
|
||||||
SafeRelease(out_layer_);
|
SafeRelease(out_layer_);
|
||||||
SafeRelease(in_layer_);
|
SafeRelease(in_layer_);
|
||||||
|
|
@ -45,12 +45,12 @@ e2d::Transition::~Transition()
|
||||||
SafeRelease(in_scene_);
|
SafeRelease(in_scene_);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Transition::IsDone()
|
bool easy2d::Transition::IsDone()
|
||||||
{
|
{
|
||||||
return done_;
|
return done_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Transition::Init(Scene * prev, Scene * next, Game * game)
|
void easy2d::Transition::Init(Scene * prev, Scene * next, Game * game)
|
||||||
{
|
{
|
||||||
started_ = Time::Now();
|
started_ = Time::Now();
|
||||||
out_scene_ = prev;
|
out_scene_ = prev;
|
||||||
|
|
@ -94,7 +94,7 @@ void e2d::Transition::Init(Scene * prev, Scene * next, Game * game)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Transition::Update()
|
void easy2d::Transition::Update()
|
||||||
{
|
{
|
||||||
if (duration_ == 0)
|
if (duration_ == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -112,7 +112,7 @@ void e2d::Transition::Update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Transition::Draw()
|
void easy2d::Transition::Draw()
|
||||||
{
|
{
|
||||||
auto render_target = Device::GetGraphics()->GetRenderTarget();
|
auto render_target = Device::GetGraphics()->GetRenderTarget();
|
||||||
|
|
||||||
|
|
@ -157,7 +157,7 @@ void e2d::Transition::Draw()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Transition::Stop()
|
void easy2d::Transition::Stop()
|
||||||
{
|
{
|
||||||
done_ = true;
|
done_ = true;
|
||||||
Reset();
|
Reset();
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ static const UINT kRedMask = 0xff << kRedShift;
|
||||||
static const UINT kGreenMask = 0xff << kGreenShift;
|
static const UINT kGreenMask = 0xff << kGreenShift;
|
||||||
static const UINT kBlueMask = 0xff << kBlueShift;
|
static const UINT kBlueMask = 0xff << kBlueShift;
|
||||||
|
|
||||||
e2d::Color::Color()
|
easy2d::Color::Color()
|
||||||
: r(0)
|
: r(0)
|
||||||
, g(0)
|
, g(0)
|
||||||
, b(0)
|
, b(0)
|
||||||
|
|
@ -36,7 +36,7 @@ e2d::Color::Color()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Color::Color(float r, float g, float b)
|
easy2d::Color::Color(float r, float g, float b)
|
||||||
: r(r)
|
: r(r)
|
||||||
, g(g)
|
, g(g)
|
||||||
, b(b)
|
, b(b)
|
||||||
|
|
@ -44,7 +44,7 @@ e2d::Color::Color(float r, float g, float b)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Color::Color(float r, float g, float b, float alpha)
|
easy2d::Color::Color(float r, float g, float b, float alpha)
|
||||||
: r(r)
|
: r(r)
|
||||||
, g(g)
|
, g(g)
|
||||||
, b(b)
|
, b(b)
|
||||||
|
|
@ -52,7 +52,7 @@ e2d::Color::Color(float r, float g, float b, float alpha)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Color::Color(UINT rgb)
|
easy2d::Color::Color(UINT rgb)
|
||||||
: r(((rgb & kRedMask) >> kRedShift) / 255.f)
|
: r(((rgb & kRedMask) >> kRedShift) / 255.f)
|
||||||
, g(((rgb & kGreenMask) >> kGreenShift) / 255.f)
|
, g(((rgb & kGreenMask) >> kGreenShift) / 255.f)
|
||||||
, b(((rgb & kBlueMask) >> kBlueShift) / 255.f)
|
, b(((rgb & kBlueMask) >> kBlueShift) / 255.f)
|
||||||
|
|
@ -60,7 +60,7 @@ e2d::Color::Color(UINT rgb)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Color::Color(UINT rgb, float alpha)
|
easy2d::Color::Color(UINT rgb, float alpha)
|
||||||
: r(((rgb & kRedMask) >> kRedShift) / 255.f)
|
: r(((rgb & kRedMask) >> kRedShift) / 255.f)
|
||||||
, g(((rgb & kGreenMask) >> kGreenShift) / 255.f)
|
, g(((rgb & kGreenMask) >> kGreenShift) / 255.f)
|
||||||
, b(((rgb & kBlueMask) >> kBlueShift) / 255.f)
|
, b(((rgb & kBlueMask) >> kBlueShift) / 255.f)
|
||||||
|
|
@ -68,7 +68,7 @@ e2d::Color::Color(UINT rgb, float alpha)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Color::Color(const D2D1_COLOR_F& color)
|
easy2d::Color::Color(const D2D1_COLOR_F& color)
|
||||||
: r(color.r)
|
: r(color.r)
|
||||||
, g(color.g)
|
, g(color.g)
|
||||||
, b(color.b)
|
, b(color.b)
|
||||||
|
|
@ -76,7 +76,7 @@ e2d::Color::Color(const D2D1_COLOR_F& color)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Color::operator D2D1_COLOR_F() const
|
easy2d::Color::operator D2D1_COLOR_F() const
|
||||||
{
|
{
|
||||||
D2D1::ColorF color_f(r, g, b, a);
|
D2D1::ColorF color_f(r, g, b, a);
|
||||||
return std::move(color_f);
|
return std::move(color_f);
|
||||||
|
|
|
||||||
|
|
@ -22,77 +22,77 @@
|
||||||
|
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
|
|
||||||
e2d::Duration::Duration()
|
easy2d::Duration::Duration()
|
||||||
: duration_ms_()
|
: duration_ms_()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Duration::Duration(float seconds)
|
easy2d::Duration::Duration(float seconds)
|
||||||
: duration_ms_(static_cast<long long>(seconds * 1000.f))
|
: duration_ms_(static_cast<long long>(seconds * 1000.f))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int e2d::Duration::Milliseconds() const
|
int easy2d::Duration::Milliseconds() const
|
||||||
{
|
{
|
||||||
return static_cast<int>(duration_ms_.count());
|
return static_cast<int>(duration_ms_.count());
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Duration::Seconds() const
|
float easy2d::Duration::Seconds() const
|
||||||
{
|
{
|
||||||
return duration_ms_.count() / 1000.f;
|
return duration_ms_.count() / 1000.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Duration::operator==(const Duration & other) const
|
bool easy2d::Duration::operator==(const Duration & other) const
|
||||||
{
|
{
|
||||||
return duration_ms_ == other.duration_ms_;
|
return duration_ms_ == other.duration_ms_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Duration::operator!=(const Duration & other) const
|
bool easy2d::Duration::operator!=(const Duration & other) const
|
||||||
{
|
{
|
||||||
return duration_ms_ != other.duration_ms_;
|
return duration_ms_ != other.duration_ms_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Duration::operator>(const Duration & other) const
|
bool easy2d::Duration::operator>(const Duration & other) const
|
||||||
{
|
{
|
||||||
return duration_ms_ > other.duration_ms_;
|
return duration_ms_ > other.duration_ms_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Duration::operator>=(const Duration & other) const
|
bool easy2d::Duration::operator>=(const Duration & other) const
|
||||||
{
|
{
|
||||||
return duration_ms_ >= other.duration_ms_;
|
return duration_ms_ >= other.duration_ms_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Duration::operator<(const Duration & other) const
|
bool easy2d::Duration::operator<(const Duration & other) const
|
||||||
{
|
{
|
||||||
return duration_ms_ < other.duration_ms_;
|
return duration_ms_ < other.duration_ms_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Duration::operator<=(const Duration & other) const
|
bool easy2d::Duration::operator<=(const Duration & other) const
|
||||||
{
|
{
|
||||||
return duration_ms_ <= other.duration_ms_;
|
return duration_ms_ <= other.duration_ms_;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Duration e2d::Duration::operator+(Duration const & other) const
|
easy2d::Duration easy2d::Duration::operator+(Duration const & other) const
|
||||||
{
|
{
|
||||||
Duration d;
|
Duration d;
|
||||||
d.duration_ms_ = duration_ms_ + other.duration_ms_;
|
d.duration_ms_ = duration_ms_ + other.duration_ms_;
|
||||||
return std::move(d);
|
return std::move(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Duration e2d::Duration::operator-(Duration const & other) const
|
easy2d::Duration easy2d::Duration::operator-(Duration const & other) const
|
||||||
{
|
{
|
||||||
Duration d;
|
Duration d;
|
||||||
d.duration_ms_ = duration_ms_ - other.duration_ms_;
|
d.duration_ms_ = duration_ms_ - other.duration_ms_;
|
||||||
return std::move(d);
|
return std::move(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Duration & e2d::Duration::operator+=(Duration const &other)
|
easy2d::Duration & easy2d::Duration::operator+=(Duration const &other)
|
||||||
{
|
{
|
||||||
duration_ms_ += other.duration_ms_;
|
duration_ms_ += other.duration_ms_;
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Duration & e2d::Duration::operator-=(Duration const &other)
|
easy2d::Duration & easy2d::Duration::operator-=(Duration const &other)
|
||||||
{
|
{
|
||||||
duration_ms_ -= other.duration_ms_;
|
duration_ms_ -= other.duration_ms_;
|
||||||
return (*this);
|
return (*this);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#include "..\e2dutil.h"
|
#include "..\e2dutil.h"
|
||||||
|
|
||||||
e2d::Font::Font()
|
easy2d::Font::Font()
|
||||||
: family("")
|
: family("")
|
||||||
, size(22)
|
, size(22)
|
||||||
, weight(Font::Weight::Normal)
|
, weight(Font::Weight::Normal)
|
||||||
|
|
@ -28,7 +28,7 @@ e2d::Font::Font()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Font::Font(const String & family, float size, UINT weight, bool italic)
|
easy2d::Font::Font(const String & family, float size, UINT weight, bool italic)
|
||||||
: family(family)
|
: family(family)
|
||||||
, size(size)
|
, size(size)
|
||||||
, weight(weight)
|
, weight(weight)
|
||||||
|
|
|
||||||
|
|
@ -20,21 +20,21 @@
|
||||||
|
|
||||||
#include "..\e2dutil.h"
|
#include "..\e2dutil.h"
|
||||||
|
|
||||||
e2d::Function::Function()
|
easy2d::Function::Function()
|
||||||
: func_(nullptr)
|
: func_(nullptr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
e2d::Function::Function(std::nullptr_t)
|
easy2d::Function::Function(std::nullptr_t)
|
||||||
: func_(nullptr)
|
: func_(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Function::Function(std::function<void()> func)
|
easy2d::Function::Function(std::function<void()> func)
|
||||||
: func_(func)
|
: func_(func)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Function::operator()(void) const
|
void easy2d::Function::operator()(void) const
|
||||||
{
|
{
|
||||||
if (func_)
|
if (func_)
|
||||||
{
|
{
|
||||||
|
|
@ -42,7 +42,7 @@ void e2d::Function::operator()(void) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Function::operator bool() const
|
easy2d::Function::operator bool() const
|
||||||
{
|
{
|
||||||
return static_cast<bool>(func_);
|
return static_cast<bool>(func_);
|
||||||
}
|
}
|
||||||
|
|
@ -22,50 +22,50 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
|
||||||
e2d::Point::Point()
|
easy2d::Point::Point()
|
||||||
{
|
{
|
||||||
x = 0;
|
x = 0;
|
||||||
y = 0;
|
y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Point::Point(float x, float y)
|
easy2d::Point::Point(float x, float y)
|
||||||
{
|
{
|
||||||
this->x = x;
|
this->x = x;
|
||||||
this->y = y;
|
this->y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Point::Point(const Point & other)
|
easy2d::Point::Point(const Point & other)
|
||||||
{
|
{
|
||||||
x = other.x;
|
x = other.x;
|
||||||
y = other.y;
|
y = other.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Point e2d::Point::operator+(const Point & p) const
|
easy2d::Point easy2d::Point::operator+(const Point & p) const
|
||||||
{
|
{
|
||||||
return Point(x + p.x, y + p.y);
|
return Point(x + p.x, y + p.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Point e2d::Point::operator-(const Point & p) const
|
easy2d::Point easy2d::Point::operator-(const Point & p) const
|
||||||
{
|
{
|
||||||
return Point(x - p.x, y - p.y);
|
return Point(x - p.x, y - p.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Point e2d::Point::operator*(float value) const
|
easy2d::Point easy2d::Point::operator*(float value) const
|
||||||
{
|
{
|
||||||
return Point(x * value, y * value);
|
return Point(x * value, y * value);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Point e2d::Point::operator/(float value) const
|
easy2d::Point easy2d::Point::operator/(float value) const
|
||||||
{
|
{
|
||||||
return Point(x / value, y / value);
|
return Point(x / value, y / value);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Point::operator e2d::Size() const
|
easy2d::Point::operator easy2d::Size() const
|
||||||
{
|
{
|
||||||
return Size(x, y);
|
return Size(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Point::Distance(const Point &p1, const Point &p2)
|
float easy2d::Point::Distance(const Point &p1, const Point &p2)
|
||||||
{
|
{
|
||||||
return sqrt(
|
return sqrt(
|
||||||
(p1.x - p2.x) * (p1.x - p2.x) +
|
(p1.x - p2.x) * (p1.x - p2.x) +
|
||||||
|
|
@ -73,12 +73,12 @@ float e2d::Point::Distance(const Point &p1, const Point &p2)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Point e2d::Point::operator-() const
|
easy2d::Point easy2d::Point::operator-() const
|
||||||
{
|
{
|
||||||
return Point(-x, -y);
|
return Point(-x, -y);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Point::operator==(const Point & point) const
|
bool easy2d::Point::operator==(const Point & point) const
|
||||||
{
|
{
|
||||||
return (x == point.x) && (y == point.y);
|
return (x == point.x) && (y == point.y);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,43 +20,43 @@
|
||||||
|
|
||||||
#include "..\e2dutil.h"
|
#include "..\e2dutil.h"
|
||||||
|
|
||||||
e2d::Rect::Rect(void)
|
easy2d::Rect::Rect(void)
|
||||||
: origin()
|
: origin()
|
||||||
, size()
|
, size()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Rect::Rect(float x, float y, float width, float height)
|
easy2d::Rect::Rect(float x, float y, float width, float height)
|
||||||
: origin(x, y)
|
: origin(x, y)
|
||||||
, size(width, height)
|
, size(width, height)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Rect::Rect(const Point& pos, const Size& size)
|
easy2d::Rect::Rect(const Point& pos, const Size& size)
|
||||||
: origin(pos.x, pos.y)
|
: origin(pos.x, pos.y)
|
||||||
, size(size.width, size.height)
|
, size(size.width, size.height)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Rect::Rect(const Rect& other)
|
easy2d::Rect::Rect(const Rect& other)
|
||||||
: origin(other.origin.x, other.origin.y)
|
: origin(other.origin.x, other.origin.y)
|
||||||
, size(other.size.width, other.size.height)
|
, size(other.size.width, other.size.height)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Rect& e2d::Rect::operator= (const Rect& other)
|
easy2d::Rect& easy2d::Rect::operator= (const Rect& other)
|
||||||
{
|
{
|
||||||
origin = other.origin;
|
origin = other.origin;
|
||||||
size = other.size;
|
size = other.size;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Rect::operator==(const Rect & rect) const
|
bool easy2d::Rect::operator==(const Rect & rect) const
|
||||||
{
|
{
|
||||||
return (origin == rect.origin) && (size == rect.size);
|
return (origin == rect.origin) && (size == rect.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Rect::ContainsPoint(const Point& point) const
|
bool easy2d::Rect::ContainsPoint(const Point& point) const
|
||||||
{
|
{
|
||||||
if (point.x >= origin.x && point.x <= (origin.y + size.height)
|
if (point.x >= origin.x && point.x <= (origin.y + size.height)
|
||||||
&& point.y >= origin.y && point.y <= (origin.y + size.height))
|
&& point.y >= origin.y && point.y <= (origin.y + size.height))
|
||||||
|
|
@ -66,7 +66,7 @@ bool e2d::Rect::ContainsPoint(const Point& point) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Rect::Intersects(const Rect& rect) const
|
bool easy2d::Rect::Intersects(const Rect& rect) const
|
||||||
{
|
{
|
||||||
return !((origin.x + size.width) < rect.origin.x ||
|
return !((origin.x + size.width) < rect.origin.x ||
|
||||||
(rect.origin.x + rect.size.width) < origin.x ||
|
(rect.origin.x + rect.size.width) < origin.x ||
|
||||||
|
|
|
||||||
|
|
@ -20,21 +20,21 @@
|
||||||
|
|
||||||
#include "..\e2dobject.h"
|
#include "..\e2dobject.h"
|
||||||
|
|
||||||
e2d::Ref::Ref()
|
easy2d::Ref::Ref()
|
||||||
: ref_count_(0)
|
: ref_count_(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Ref::~Ref()
|
easy2d::Ref::~Ref()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
LONG e2d::Ref::Retain()
|
LONG easy2d::Ref::Retain()
|
||||||
{
|
{
|
||||||
return ::InterlockedIncrement(&ref_count_);
|
return ::InterlockedIncrement(&ref_count_);
|
||||||
}
|
}
|
||||||
|
|
||||||
LONG e2d::Ref::Release()
|
LONG easy2d::Ref::Release()
|
||||||
{
|
{
|
||||||
LONG new_count = ::InterlockedDecrement(&ref_count_);
|
LONG new_count = ::InterlockedDecrement(&ref_count_);
|
||||||
|
|
||||||
|
|
@ -47,7 +47,7 @@ LONG e2d::Ref::Release()
|
||||||
return new_count;
|
return new_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
LONG e2d::Ref::GetRefCount() const
|
LONG easy2d::Ref::GetRefCount() const
|
||||||
{
|
{
|
||||||
return ref_count_;
|
return ref_count_;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
#include "..\e2dtool.h"
|
#include "..\e2dtool.h"
|
||||||
|
|
||||||
|
|
||||||
e2d::Resource::Resource(int resource_id, const String & resource_type)
|
easy2d::Resource::Resource(int resource_id, const String & resource_type)
|
||||||
: id(resource_id)
|
: id(resource_id)
|
||||||
, type(resource_type)
|
, type(resource_type)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -20,55 +20,55 @@
|
||||||
|
|
||||||
#include "..\e2dutil.h"
|
#include "..\e2dutil.h"
|
||||||
|
|
||||||
e2d::Size::Size()
|
easy2d::Size::Size()
|
||||||
{
|
{
|
||||||
width = 0;
|
width = 0;
|
||||||
height = 0;
|
height = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Size::Size(float width, float height)
|
easy2d::Size::Size(float width, float height)
|
||||||
{
|
{
|
||||||
this->width = width;
|
this->width = width;
|
||||||
this->height = height;
|
this->height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Size::Size(const Size & other)
|
easy2d::Size::Size(const Size & other)
|
||||||
{
|
{
|
||||||
width = other.width;
|
width = other.width;
|
||||||
height = other.height;
|
height = other.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Size e2d::Size::operator+(const Size & other) const
|
easy2d::Size easy2d::Size::operator+(const Size & other) const
|
||||||
{
|
{
|
||||||
return Size(width + other.width, height + other.height);
|
return Size(width + other.width, height + other.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Size e2d::Size::operator-(const Size & other) const
|
easy2d::Size easy2d::Size::operator-(const Size & other) const
|
||||||
{
|
{
|
||||||
return Size(width - other.width, height - other.height);
|
return Size(width - other.width, height - other.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Size e2d::Size::operator*(float value) const
|
easy2d::Size easy2d::Size::operator*(float value) const
|
||||||
{
|
{
|
||||||
return Size(width * value, height * value);
|
return Size(width * value, height * value);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Size e2d::Size::operator/(float value) const
|
easy2d::Size easy2d::Size::operator/(float value) const
|
||||||
{
|
{
|
||||||
return Size(width / value, height / value);
|
return Size(width / value, height / value);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Size::operator e2d::Point() const
|
easy2d::Size::operator easy2d::Point() const
|
||||||
{
|
{
|
||||||
return Point(width, height);
|
return Point(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Size e2d::Size::operator-() const
|
easy2d::Size easy2d::Size::operator-() const
|
||||||
{
|
{
|
||||||
return Size(-width, -height);
|
return Size(-width, -height);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Size::operator==(const Size & other) const
|
bool easy2d::Size::operator==(const Size & other) const
|
||||||
{
|
{
|
||||||
return (width == other.width) && (height == other.height);
|
return (width == other.width) && (height == other.height);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,77 +25,77 @@
|
||||||
#pragma comment(lib, "comsuppw.lib")
|
#pragma comment(lib, "comsuppw.lib")
|
||||||
|
|
||||||
|
|
||||||
e2d::String::String()
|
easy2d::String::String()
|
||||||
: string_(L"")
|
: string_(L"")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String::String(const wchar_t *str)
|
easy2d::String::String(const wchar_t *str)
|
||||||
: string_(str)
|
: string_(str)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String::String(const char *cstr)
|
easy2d::String::String(const char *cstr)
|
||||||
: string_(static_cast<wchar_t*>(_bstr_t(cstr)))
|
: string_(static_cast<wchar_t*>(_bstr_t(cstr)))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String::String(e2d::String && str)
|
easy2d::String::String(easy2d::String && str)
|
||||||
{
|
{
|
||||||
string_ = std::move(str.string_);
|
string_ = std::move(str.string_);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String::String(const e2d::String &str)
|
easy2d::String::String(const easy2d::String &str)
|
||||||
: string_(str.string_)
|
: string_(str.string_)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String::~String()
|
easy2d::String::~String()
|
||||||
{
|
{
|
||||||
string_.clear();
|
string_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String &e2d::String::operator=(const wchar_t *str)
|
easy2d::String &easy2d::String::operator=(const wchar_t *str)
|
||||||
{
|
{
|
||||||
string_ = str;
|
string_ = str;
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String & e2d::String::operator=(const char *cstr)
|
easy2d::String & easy2d::String::operator=(const char *cstr)
|
||||||
{
|
{
|
||||||
string_ = static_cast<wchar_t*>(_bstr_t(cstr));
|
string_ = static_cast<wchar_t*>(_bstr_t(cstr));
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String e2d::String::Parse(int value)
|
easy2d::String easy2d::String::Parse(int value)
|
||||||
{
|
{
|
||||||
String tmp;
|
String tmp;
|
||||||
tmp.string_ = std::to_wstring(value);
|
tmp.string_ = std::to_wstring(value);
|
||||||
return std::move(tmp);
|
return std::move(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String e2d::String::Parse(unsigned int value)
|
easy2d::String easy2d::String::Parse(unsigned int value)
|
||||||
{
|
{
|
||||||
String tmp;
|
String tmp;
|
||||||
tmp.string_ = std::to_wstring(value);
|
tmp.string_ = std::to_wstring(value);
|
||||||
return std::move(tmp);
|
return std::move(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String e2d::String::Parse(float value)
|
easy2d::String easy2d::String::Parse(float value)
|
||||||
{
|
{
|
||||||
String tmp;
|
String tmp;
|
||||||
tmp.string_ = std::to_wstring(value);
|
tmp.string_ = std::to_wstring(value);
|
||||||
return std::move(tmp);
|
return std::move(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String e2d::String::Parse(double value)
|
easy2d::String easy2d::String::Parse(double value)
|
||||||
{
|
{
|
||||||
String tmp;
|
String tmp;
|
||||||
tmp.string_ = std::to_wstring(value);
|
tmp.string_ = std::to_wstring(value);
|
||||||
return std::move(tmp);
|
return std::move(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String e2d::String::Format(const char * format, ...)
|
easy2d::String easy2d::String::Format(const char * format, ...)
|
||||||
{
|
{
|
||||||
std::string tmp;
|
std::string tmp;
|
||||||
|
|
||||||
|
|
@ -117,7 +117,7 @@ e2d::String e2d::String::Format(const char * format, ...)
|
||||||
return std::move(str);
|
return std::move(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String e2d::String::Format(const wchar_t * format, ...)
|
easy2d::String easy2d::String::Format(const wchar_t * format, ...)
|
||||||
{
|
{
|
||||||
std::wstring tmp;
|
std::wstring tmp;
|
||||||
|
|
||||||
|
|
@ -139,13 +139,13 @@ e2d::String e2d::String::Format(const wchar_t * format, ...)
|
||||||
return std::move(str);
|
return std::move(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String & e2d::String::operator=(const String &str)
|
easy2d::String & easy2d::String::operator=(const String &str)
|
||||||
{
|
{
|
||||||
string_ = str.string_;
|
string_ = str.string_;
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::String::operator==(const wchar_t *str) const
|
bool easy2d::String::operator==(const wchar_t *str) const
|
||||||
{
|
{
|
||||||
if (str)
|
if (str)
|
||||||
{
|
{
|
||||||
|
|
@ -157,7 +157,7 @@ bool e2d::String::operator==(const wchar_t *str) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::String::operator==(const char *str) const
|
bool easy2d::String::operator==(const char *str) const
|
||||||
{
|
{
|
||||||
if (str)
|
if (str)
|
||||||
{
|
{
|
||||||
|
|
@ -170,12 +170,12 @@ bool e2d::String::operator==(const char *str) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::String::operator ==(const e2d::String &str) const
|
bool easy2d::String::operator ==(const easy2d::String &str) const
|
||||||
{
|
{
|
||||||
return string_ == str.string_;
|
return string_ == str.string_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::String::operator!=(const wchar_t *str) const
|
bool easy2d::String::operator!=(const wchar_t *str) const
|
||||||
{
|
{
|
||||||
if (str)
|
if (str)
|
||||||
{
|
{
|
||||||
|
|
@ -187,7 +187,7 @@ bool e2d::String::operator!=(const wchar_t *str) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::String::operator!=(const char *str) const
|
bool easy2d::String::operator!=(const char *str) const
|
||||||
{
|
{
|
||||||
if (str)
|
if (str)
|
||||||
{
|
{
|
||||||
|
|
@ -200,205 +200,205 @@ bool e2d::String::operator!=(const char *str) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::String::operator!=(const e2d::String &str) const
|
bool easy2d::String::operator!=(const easy2d::String &str) const
|
||||||
{
|
{
|
||||||
return string_ != str.string_;
|
return string_ != str.string_;
|
||||||
}
|
}
|
||||||
|
|
||||||
wchar_t &e2d::String::operator[](size_t index)
|
wchar_t &easy2d::String::operator[](size_t index)
|
||||||
{
|
{
|
||||||
return string_[index];
|
return string_[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String e2d::String::operator+(const wchar_t *str) const
|
easy2d::String easy2d::String::operator+(const wchar_t *str) const
|
||||||
{
|
{
|
||||||
String temp;
|
String temp;
|
||||||
temp.string_ = string_ + str;
|
temp.string_ = string_ + str;
|
||||||
return std::move(temp);
|
return std::move(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String e2d::String::operator+(const char *str) const
|
easy2d::String easy2d::String::operator+(const char *str) const
|
||||||
{
|
{
|
||||||
String temp;
|
String temp;
|
||||||
temp.string_ = string_ + static_cast<wchar_t*>(_bstr_t(str));
|
temp.string_ = string_ + static_cast<wchar_t*>(_bstr_t(str));
|
||||||
return std::move(temp);
|
return std::move(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String e2d::String::operator+(const e2d::String &str) const
|
easy2d::String easy2d::String::operator+(const easy2d::String &str) const
|
||||||
{
|
{
|
||||||
String temp;
|
String temp;
|
||||||
temp.string_ = string_ + str.string_;
|
temp.string_ = string_ + str.string_;
|
||||||
return std::move(temp);
|
return std::move(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String e2d::operator+(const wchar_t *str1, const e2d::String &str2)
|
easy2d::String easy2d::operator+(const wchar_t *str1, const easy2d::String &str2)
|
||||||
{
|
{
|
||||||
String temp;
|
String temp;
|
||||||
temp.string_ = str1 + str2.string_;
|
temp.string_ = str1 + str2.string_;
|
||||||
return std::move(temp);
|
return std::move(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String e2d::operator+(const char *str1, const String &str2)
|
easy2d::String easy2d::operator+(const char *str1, const String &str2)
|
||||||
{
|
{
|
||||||
String temp;
|
String temp;
|
||||||
temp.string_ = static_cast<wchar_t*>(_bstr_t(str1)) + str2.string_;
|
temp.string_ = static_cast<wchar_t*>(_bstr_t(str1)) + str2.string_;
|
||||||
return std::move(temp);
|
return std::move(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String & e2d::String::operator+=(const wchar_t *str)
|
easy2d::String & easy2d::String::operator+=(const wchar_t *str)
|
||||||
{
|
{
|
||||||
string_ += str;
|
string_ += str;
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String & e2d::String::operator+=(const char *str)
|
easy2d::String & easy2d::String::operator+=(const char *str)
|
||||||
{
|
{
|
||||||
string_ += static_cast<wchar_t*>(_bstr_t(str));
|
string_ += static_cast<wchar_t*>(_bstr_t(str));
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String & e2d::String::operator+=(const String &str)
|
easy2d::String & easy2d::String::operator+=(const String &str)
|
||||||
{
|
{
|
||||||
string_ += str.string_;
|
string_ += str.string_;
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::String::operator>(const String &str) const
|
bool easy2d::String::operator>(const String &str) const
|
||||||
{
|
{
|
||||||
return string_ > str.string_;
|
return string_ > str.string_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::String::operator>=(const String &str) const
|
bool easy2d::String::operator>=(const String &str) const
|
||||||
{
|
{
|
||||||
return string_ >= str.string_;
|
return string_ >= str.string_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::String::operator<(const String &str) const
|
bool easy2d::String::operator<(const String &str) const
|
||||||
{
|
{
|
||||||
return string_ < str.string_;
|
return string_ < str.string_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::String::operator<=(const String &str) const
|
bool easy2d::String::operator<=(const String &str) const
|
||||||
{
|
{
|
||||||
return string_ <= str.string_;
|
return string_ <= str.string_;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String & e2d::String::operator<<(const String &str)
|
easy2d::String & easy2d::String::operator<<(const String &str)
|
||||||
{
|
{
|
||||||
string_ += str.string_;
|
string_ += str.string_;
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String & e2d::String::operator<<(const wchar_t *str)
|
easy2d::String & easy2d::String::operator<<(const wchar_t *str)
|
||||||
{
|
{
|
||||||
string_ += str;
|
string_ += str;
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String & e2d::String::operator<<(wchar_t *str)
|
easy2d::String & easy2d::String::operator<<(wchar_t *str)
|
||||||
{
|
{
|
||||||
string_ += str;
|
string_ += str;
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String & e2d::String::operator<<(const char * cstr)
|
easy2d::String & easy2d::String::operator<<(const char * cstr)
|
||||||
{
|
{
|
||||||
string_ += static_cast<wchar_t*>(_bstr_t(cstr));
|
string_ += static_cast<wchar_t*>(_bstr_t(cstr));
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String & e2d::String::operator<<(char * cstr)
|
easy2d::String & easy2d::String::operator<<(char * cstr)
|
||||||
{
|
{
|
||||||
string_ += static_cast<wchar_t*>(_bstr_t(cstr));
|
string_ += static_cast<wchar_t*>(_bstr_t(cstr));
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String & e2d::String::operator<<(int value)
|
easy2d::String & easy2d::String::operator<<(int value)
|
||||||
{
|
{
|
||||||
(*this) += String::Parse(value);
|
(*this) += String::Parse(value);
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String & e2d::String::operator<<(unsigned int value)
|
easy2d::String & easy2d::String::operator<<(unsigned int value)
|
||||||
{
|
{
|
||||||
(*this) += String::Parse(value);
|
(*this) += String::Parse(value);
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String & e2d::String::operator<<(float value)
|
easy2d::String & easy2d::String::operator<<(float value)
|
||||||
{
|
{
|
||||||
(*this) += String::Parse(value);
|
(*this) += String::Parse(value);
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String & e2d::String::operator<<(double value)
|
easy2d::String & easy2d::String::operator<<(double value)
|
||||||
{
|
{
|
||||||
(*this) += String::Parse(value);
|
(*this) += String::Parse(value);
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String::operator const wchar_t*() const
|
easy2d::String::operator const wchar_t*() const
|
||||||
{
|
{
|
||||||
return string_.c_str();
|
return string_.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String::operator wchar_t*() const
|
easy2d::String::operator wchar_t*() const
|
||||||
{
|
{
|
||||||
return const_cast<wchar_t*>(string_.c_str());
|
return const_cast<wchar_t*>(string_.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String::operator std::wstring() const
|
easy2d::String::operator std::wstring() const
|
||||||
{
|
{
|
||||||
return string_;
|
return string_;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String::operator std::string() const
|
easy2d::String::operator std::string() const
|
||||||
{
|
{
|
||||||
std::string str = static_cast<const char *>(_bstr_t(string_.c_str()));
|
std::string str = static_cast<const char *>(_bstr_t(string_.c_str()));
|
||||||
return std::move(str);
|
return std::move(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::String::IsEmpty() const
|
bool easy2d::String::IsEmpty() const
|
||||||
{
|
{
|
||||||
return string_.empty();
|
return string_.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
int e2d::String::GetLength() const
|
int easy2d::String::GetLength() const
|
||||||
{
|
{
|
||||||
return static_cast<int>(string_.size());
|
return static_cast<int>(string_.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t e2d::String::GetHash() const
|
size_t easy2d::String::GetHash() const
|
||||||
{
|
{
|
||||||
std::hash<std::wstring> hash;
|
std::hash<std::wstring> hash;
|
||||||
return hash(string_);
|
return hash(string_);
|
||||||
}
|
}
|
||||||
|
|
||||||
const wchar_t& e2d::String::At(size_t index) const
|
const wchar_t& easy2d::String::At(size_t index) const
|
||||||
{
|
{
|
||||||
return string_.at(index);
|
return string_.at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
int e2d::String::Compare(const String & str) const
|
int easy2d::String::Compare(const String & str) const
|
||||||
{
|
{
|
||||||
return string_.compare(str.string_);
|
return string_.compare(str.string_);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String e2d::String::ToUpper() const
|
easy2d::String easy2d::String::ToUpper() const
|
||||||
{
|
{
|
||||||
String str(*this);
|
String str(*this);
|
||||||
std::transform(str.string_.begin(), str.string_.end(), str.string_.begin(), std::towupper);
|
std::transform(str.string_.begin(), str.string_.end(), str.string_.begin(), std::towupper);
|
||||||
return std::move(str);
|
return std::move(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String e2d::String::ToLower() const
|
easy2d::String easy2d::String::ToLower() const
|
||||||
{
|
{
|
||||||
e2d::String str(*this);
|
easy2d::String str(*this);
|
||||||
std::transform(str.string_.begin(), str.string_.end(), str.string_.begin(), std::towlower);
|
std::transform(str.string_.begin(), str.string_.end(), str.string_.begin(), std::towlower);
|
||||||
return std::move(str);
|
return std::move(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
int e2d::String::ToInt() const
|
int easy2d::String::ToInt() const
|
||||||
{
|
{
|
||||||
if (string_.empty())
|
if (string_.empty())
|
||||||
{
|
{
|
||||||
|
|
@ -407,7 +407,7 @@ int e2d::String::ToInt() const
|
||||||
return std::stoi(string_, 0, 10);
|
return std::stoi(string_, 0, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::String::ToFloat() const
|
float easy2d::String::ToFloat() const
|
||||||
{
|
{
|
||||||
if (string_.empty())
|
if (string_.empty())
|
||||||
{
|
{
|
||||||
|
|
@ -416,7 +416,7 @@ float e2d::String::ToFloat() const
|
||||||
return std::stof(string_, 0);
|
return std::stof(string_, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double e2d::String::ToDouble() const
|
double easy2d::String::ToDouble() const
|
||||||
{
|
{
|
||||||
if (string_.empty())
|
if (string_.empty())
|
||||||
{
|
{
|
||||||
|
|
@ -425,7 +425,7 @@ double e2d::String::ToDouble() const
|
||||||
return std::stod(string_, 0);
|
return std::stod(string_, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::String::ToBool() const
|
bool easy2d::String::ToBool() const
|
||||||
{
|
{
|
||||||
if (string_.empty())
|
if (string_.empty())
|
||||||
{
|
{
|
||||||
|
|
@ -439,7 +439,7 @@ bool e2d::String::ToBool() const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String e2d::String::Subtract(int offset, int count) const
|
easy2d::String easy2d::String::Subtract(int offset, int count) const
|
||||||
{
|
{
|
||||||
String tmp;
|
String tmp;
|
||||||
int length = static_cast<int>(string_.size());
|
int length = static_cast<int>(string_.size());
|
||||||
|
|
@ -456,12 +456,12 @@ e2d::String e2d::String::Subtract(int offset, int count) const
|
||||||
return std::move(tmp);
|
return std::move(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::String::Insert(const String & str, int pos)
|
void easy2d::String::Insert(const String & str, int pos)
|
||||||
{
|
{
|
||||||
string_.insert(size_t(pos), str.string_);
|
string_.insert(size_t(pos), str.string_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::String::Replace(const String & from, const String & to)
|
void easy2d::String::Replace(const String & from, const String & to)
|
||||||
{
|
{
|
||||||
if (from.string_.empty())
|
if (from.string_.empty())
|
||||||
return;
|
return;
|
||||||
|
|
@ -474,12 +474,12 @@ void e2d::String::Replace(const String & from, const String & to)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::String::Erase(int offset, int count)
|
void easy2d::String::Erase(int offset, int count)
|
||||||
{
|
{
|
||||||
string_.erase(size_t(offset), size_t(count));
|
string_.erase(size_t(offset), size_t(count));
|
||||||
}
|
}
|
||||||
|
|
||||||
int e2d::String::Find(const String & str, int offset) const
|
int easy2d::String::Find(const String & str, int offset) const
|
||||||
{
|
{
|
||||||
size_t index;
|
size_t index;
|
||||||
if ((index = string_.find(str.string_, size_t(offset))) == std::wstring::npos)
|
if ((index = string_.find(str.string_, size_t(offset))) == std::wstring::npos)
|
||||||
|
|
@ -492,31 +492,31 @@ int e2d::String::Find(const String & str, int offset) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::String::Clear()
|
void easy2d::String::Clear()
|
||||||
{
|
{
|
||||||
string_.clear();
|
string_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wostream & e2d::operator<<(std::wostream &cout, const String &str)
|
std::wostream & easy2d::operator<<(std::wostream &cout, const String &str)
|
||||||
{
|
{
|
||||||
cout << str.string_;
|
cout << str.string_;
|
||||||
return cout;
|
return cout;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wistream & e2d::operator>>(std::wistream &cin, String &str)
|
std::wistream & easy2d::operator>>(std::wistream &cin, String &str)
|
||||||
{
|
{
|
||||||
cin >> str.string_;
|
cin >> str.string_;
|
||||||
return cin;
|
return cin;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream & e2d::operator<<(std::ostream &cout, const String &str)
|
std::ostream & easy2d::operator<<(std::ostream &cout, const String &str)
|
||||||
{
|
{
|
||||||
std::string cstr = static_cast<char*>(_bstr_t(str.string_.c_str()));
|
std::string cstr = static_cast<char*>(_bstr_t(str.string_.c_str()));
|
||||||
cout << cstr;
|
cout << cstr;
|
||||||
return cout;
|
return cout;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::istream & e2d::operator>>(std::istream &cin, String &str)
|
std::istream & easy2d::operator>>(std::istream &cin, String &str)
|
||||||
{
|
{
|
||||||
std::string temp;
|
std::string temp;
|
||||||
cin >> temp;
|
cin >> temp;
|
||||||
|
|
|
||||||
|
|
@ -23,54 +23,54 @@
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
|
|
||||||
|
|
||||||
e2d::Time::Time()
|
easy2d::Time::Time()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
time_t e2d::Time::GetTimeStamp() const
|
time_t easy2d::Time::GetTimeStamp() const
|
||||||
{
|
{
|
||||||
auto& duration = time_point_cast<milliseconds>(time_).time_since_epoch();
|
auto& duration = time_point_cast<milliseconds>(time_).time_since_epoch();
|
||||||
return static_cast<time_t>(duration.count());
|
return static_cast<time_t>(duration.count());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Time::IsZero() const
|
bool easy2d::Time::IsZero() const
|
||||||
{
|
{
|
||||||
return time_.time_since_epoch().count() == 0LL;
|
return time_.time_since_epoch().count() == 0LL;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Time e2d::Time::operator+(Duration const & other) const
|
easy2d::Time easy2d::Time::operator+(Duration const & other) const
|
||||||
{
|
{
|
||||||
Time t;
|
Time t;
|
||||||
t.time_ = time_ + milliseconds(other.Milliseconds());
|
t.time_ = time_ + milliseconds(other.Milliseconds());
|
||||||
return std::move(t);
|
return std::move(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Time e2d::Time::operator-(Duration const & other) const
|
easy2d::Time easy2d::Time::operator-(Duration const & other) const
|
||||||
{
|
{
|
||||||
Time t;
|
Time t;
|
||||||
t.time_ = time_ - milliseconds(other.Milliseconds());
|
t.time_ = time_ - milliseconds(other.Milliseconds());
|
||||||
return std::move(t);
|
return std::move(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Time & e2d::Time::operator+=(Duration const & other)
|
easy2d::Time & easy2d::Time::operator+=(Duration const & other)
|
||||||
{
|
{
|
||||||
time_ += milliseconds(other.Milliseconds());
|
time_ += milliseconds(other.Milliseconds());
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Time & e2d::Time::operator-=(Duration const &other)
|
easy2d::Time & easy2d::Time::operator-=(Duration const &other)
|
||||||
{
|
{
|
||||||
time_ -= milliseconds(other.Milliseconds());
|
time_ -= milliseconds(other.Milliseconds());
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Duration e2d::Time::operator-(Time const & other) const
|
easy2d::Duration easy2d::Time::operator-(Time const & other) const
|
||||||
{
|
{
|
||||||
auto ms = duration_cast<milliseconds>(time_ - other.time_).count();
|
auto ms = duration_cast<milliseconds>(time_ - other.time_).count();
|
||||||
return std::move(Duration(static_cast<float>(ms) / 1000.f));
|
return std::move(Duration(static_cast<float>(ms) / 1000.f));
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Time e2d::Time::Now()
|
easy2d::Time easy2d::Time::Now()
|
||||||
{
|
{
|
||||||
Time t;
|
Time t;
|
||||||
t.time_ = steady_clock::now();
|
t.time_ = steady_clock::now();
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
#include "..\e2dutil.h"
|
#include "..\e2dutil.h"
|
||||||
|
|
||||||
|
|
||||||
e2d::Transform::Transform()
|
easy2d::Transform::Transform()
|
||||||
: position()
|
: position()
|
||||||
, size()
|
, size()
|
||||||
, scale_x(1.f)
|
, scale_x(1.f)
|
||||||
|
|
@ -34,7 +34,7 @@ e2d::Transform::Transform()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Transform::operator D2D1::Matrix3x2F() const
|
easy2d::Transform::operator D2D1::Matrix3x2F() const
|
||||||
{
|
{
|
||||||
auto pivot = D2D1::Point2F(size.width * pivot_x, size.height * pivot_y);
|
auto pivot = D2D1::Point2F(size.width * pivot_x, size.height * pivot_y);
|
||||||
auto matrix = D2D1::Matrix3x2F::Scale(
|
auto matrix = D2D1::Matrix3x2F::Scale(
|
||||||
|
|
@ -55,7 +55,7 @@ e2d::Transform::operator D2D1::Matrix3x2F() const
|
||||||
return std::move(matrix);
|
return std::move(matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Transform::operator==(const Transform & other) const
|
bool easy2d::Transform::operator==(const Transform & other) const
|
||||||
{
|
{
|
||||||
return position == other.position &&
|
return position == other.position &&
|
||||||
size == other.size &&
|
size == other.size &&
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue