parent
46ce8726cb
commit
3b5704ee22
|
|
@ -1,45 +0,0 @@
|
|||
// Copyright (c) 2016-2018 Easy2D - Nomango
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "ResLoader.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
/*void ResLoader::Add(String const & id, SpImage const & image)
|
||||
{
|
||||
res_.insert(std::make_pair(id, image.Get()));
|
||||
}
|
||||
|
||||
void ResLoader::Add(String const & id, SpFrames const & frames)
|
||||
{
|
||||
res_.insert(std::make_pair(id, frames.Get()));
|
||||
}
|
||||
|
||||
SpImage easy2d::ResLoader::GetImage(String const & id)
|
||||
{
|
||||
return Get<Image*>(id);
|
||||
}*/
|
||||
|
||||
/*SpFrames easy2d::ResLoader::GetFrames(String const & id)
|
||||
{
|
||||
return Get<Frames*>(id);
|
||||
}*/
|
||||
|
||||
}
|
||||
|
|
@ -44,7 +44,7 @@
|
|||
<ClInclude Include="..\..\src\core\include-forwards.h" />
|
||||
<ClInclude Include="..\..\src\core\Input.h" />
|
||||
<ClInclude Include="..\..\src\core\intrusive\List.hpp" />
|
||||
<ClInclude Include="..\..\src\core\intrusive\SmartPointer.hpp" />
|
||||
<ClInclude Include="..\..\src\core\intrusive\SmartPtr.hpp" />
|
||||
<ClInclude Include="..\..\src\core\KeyEvent.hpp" />
|
||||
<ClInclude Include="..\..\src\core\keys.hpp" />
|
||||
<ClInclude Include="..\..\src\core\logs.h" />
|
||||
|
|
@ -84,6 +84,7 @@
|
|||
<ClInclude Include="..\..\src\utils\File.h" />
|
||||
<ClInclude Include="..\..\src\utils\Path.h" />
|
||||
<ClInclude Include="..\..\src\utils\Player.h" />
|
||||
<ClInclude Include="..\..\src\utils\ResLoader.h" />
|
||||
<ClInclude Include="..\..\src\utils\string.h" />
|
||||
<ClInclude Include="..\..\src\utils\Transcoder.h" />
|
||||
</ItemGroup>
|
||||
|
|
@ -129,6 +130,7 @@
|
|||
<ClCompile Include="..\..\src\utils\File.cpp" />
|
||||
<ClCompile Include="..\..\src\utils\Path.cpp" />
|
||||
<ClCompile Include="..\..\src\utils\Player.cpp" />
|
||||
<ClCompile Include="..\..\src\utils\ResLoader.cpp" />
|
||||
<ClCompile Include="..\..\src\utils\string.cpp" />
|
||||
<ClCompile Include="..\..\src\utils\Transcoder.cpp" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@
|
|||
<ClInclude Include="..\..\src\core\intrusive\List.hpp">
|
||||
<Filter>core\intrusive</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\intrusive\SmartPointer.hpp">
|
||||
<ClInclude Include="..\..\src\core\intrusive\SmartPtr.hpp">
|
||||
<Filter>core\intrusive</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\Transform.hpp">
|
||||
|
|
@ -200,6 +200,9 @@
|
|||
<ClInclude Include="..\..\src\math\Rect.hpp">
|
||||
<Filter>math</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\utils\ResLoader.h">
|
||||
<Filter>utils</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="core">
|
||||
|
|
@ -348,5 +351,8 @@
|
|||
<ClCompile Include="..\..\src\core\DebugNode.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\utils\ResLoader.cpp">
|
||||
<Filter>utils</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -44,7 +44,7 @@
|
|||
<ClInclude Include="..\..\src\core\include-forwards.h" />
|
||||
<ClInclude Include="..\..\src\core\Input.h" />
|
||||
<ClInclude Include="..\..\src\core\intrusive\List.hpp" />
|
||||
<ClInclude Include="..\..\src\core\intrusive\SmartPointer.hpp" />
|
||||
<ClInclude Include="..\..\src\core\intrusive\SmartPtr.hpp" />
|
||||
<ClInclude Include="..\..\src\core\KeyEvent.hpp" />
|
||||
<ClInclude Include="..\..\src\core\keys.hpp" />
|
||||
<ClInclude Include="..\..\src\core\logs.h" />
|
||||
|
|
@ -84,6 +84,7 @@
|
|||
<ClInclude Include="..\..\src\utils\File.h" />
|
||||
<ClInclude Include="..\..\src\utils\Path.h" />
|
||||
<ClInclude Include="..\..\src\utils\Player.h" />
|
||||
<ClInclude Include="..\..\src\utils\ResLoader.h" />
|
||||
<ClInclude Include="..\..\src\utils\string.h" />
|
||||
<ClInclude Include="..\..\src\utils\Transcoder.h" />
|
||||
</ItemGroup>
|
||||
|
|
@ -129,6 +130,7 @@
|
|||
<ClCompile Include="..\..\src\utils\File.cpp" />
|
||||
<ClCompile Include="..\..\src\utils\Path.cpp" />
|
||||
<ClCompile Include="..\..\src\utils\Player.cpp" />
|
||||
<ClCompile Include="..\..\src\utils\ResLoader.cpp" />
|
||||
<ClCompile Include="..\..\src\utils\string.cpp" />
|
||||
<ClCompile Include="..\..\src\utils\Transcoder.cpp" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@
|
|||
<ClInclude Include="..\..\src\core\intrusive\List.hpp">
|
||||
<Filter>core\intrusive</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\intrusive\SmartPointer.hpp">
|
||||
<ClInclude Include="..\..\src\core\intrusive\SmartPtr.hpp">
|
||||
<Filter>core\intrusive</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\Transform.hpp">
|
||||
|
|
@ -200,6 +200,9 @@
|
|||
<ClInclude Include="..\..\src\math\Rect.hpp">
|
||||
<Filter>math</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\utils\ResLoader.h">
|
||||
<Filter>utils</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="core">
|
||||
|
|
@ -348,5 +351,8 @@
|
|||
<ClCompile Include="..\..\src\core\DebugNode.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\utils\ResLoader.cpp">
|
||||
<Filter>utils</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -44,7 +44,7 @@
|
|||
<ClInclude Include="..\..\src\core\include-forwards.h" />
|
||||
<ClInclude Include="..\..\src\core\Input.h" />
|
||||
<ClInclude Include="..\..\src\core\intrusive\List.hpp" />
|
||||
<ClInclude Include="..\..\src\core\intrusive\SmartPointer.hpp" />
|
||||
<ClInclude Include="..\..\src\core\intrusive\SmartPtr.hpp" />
|
||||
<ClInclude Include="..\..\src\core\KeyEvent.hpp" />
|
||||
<ClInclude Include="..\..\src\core\keys.hpp" />
|
||||
<ClInclude Include="..\..\src\core\logs.h" />
|
||||
|
|
@ -84,6 +84,7 @@
|
|||
<ClInclude Include="..\..\src\utils\File.h" />
|
||||
<ClInclude Include="..\..\src\utils\Path.h" />
|
||||
<ClInclude Include="..\..\src\utils\Player.h" />
|
||||
<ClInclude Include="..\..\src\utils\ResLoader.h" />
|
||||
<ClInclude Include="..\..\src\utils\string.h" />
|
||||
<ClInclude Include="..\..\src\utils\Transcoder.h" />
|
||||
</ItemGroup>
|
||||
|
|
@ -129,6 +130,7 @@
|
|||
<ClCompile Include="..\..\src\utils\File.cpp" />
|
||||
<ClCompile Include="..\..\src\utils\Path.cpp" />
|
||||
<ClCompile Include="..\..\src\utils\Player.cpp" />
|
||||
<ClCompile Include="..\..\src\utils\ResLoader.cpp" />
|
||||
<ClCompile Include="..\..\src\utils\string.cpp" />
|
||||
<ClCompile Include="..\..\src\utils\Transcoder.cpp" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@
|
|||
<ClInclude Include="..\..\src\core\intrusive\List.hpp">
|
||||
<Filter>core\intrusive</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\intrusive\SmartPointer.hpp">
|
||||
<ClInclude Include="..\..\src\core\intrusive\SmartPtr.hpp">
|
||||
<Filter>core\intrusive</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\Transform.hpp">
|
||||
|
|
@ -200,6 +200,9 @@
|
|||
<ClInclude Include="..\..\src\math\Rect.hpp">
|
||||
<Filter>math</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\utils\ResLoader.h">
|
||||
<Filter>utils</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="core">
|
||||
|
|
@ -348,5 +351,8 @@
|
|||
<ClCompile Include="..\..\src\core\DebugNode.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\utils\ResLoader.cpp">
|
||||
<Filter>utils</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -30,13 +30,13 @@ namespace easy2d
|
|||
|
||||
class Action
|
||||
: public Object
|
||||
, protected intrusive::ListItem<SpAction>
|
||||
, protected intrusive::ListItem<ActionPtr>
|
||||
{
|
||||
friend class ActionManager;
|
||||
friend class Loop;
|
||||
friend class Sequence;
|
||||
friend class Spawn;
|
||||
friend class intrusive::List<SpAction>;
|
||||
friend class intrusive::List<ActionPtr>;
|
||||
|
||||
public:
|
||||
Action() : running_(false), done_(false), initialized_(false) {}
|
||||
|
|
@ -56,10 +56,10 @@ namespace easy2d
|
|||
virtual void Stop() { if (!done_) { done_ = true; if (cb_) cb_(); } }
|
||||
|
||||
// 获取动作的拷贝
|
||||
virtual SpAction Clone() const = 0;
|
||||
virtual ActionPtr Clone() const = 0;
|
||||
|
||||
// 获取动作的倒转
|
||||
virtual SpAction Reverse() const = 0;
|
||||
virtual ActionPtr Reverse() const = 0;
|
||||
|
||||
// 重置动作
|
||||
virtual void Reset()
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ namespace easy2d
|
|||
// Loop
|
||||
//-------------------------------------------------------
|
||||
|
||||
Loop::Loop(SpAction const& action, int times)
|
||||
Loop::Loop(ActionPtr const& action, int times)
|
||||
: action_(action)
|
||||
, times_(0)
|
||||
, total_times_(times)
|
||||
|
|
@ -41,7 +41,7 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
SpAction Loop::Clone() const
|
||||
ActionPtr Loop::Clone() const
|
||||
{
|
||||
if (action_)
|
||||
{
|
||||
|
|
@ -53,7 +53,7 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
SpAction Loop::Reverse() const
|
||||
ActionPtr Loop::Reverse() const
|
||||
{
|
||||
if (action_)
|
||||
{
|
||||
|
|
@ -125,7 +125,7 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
Sequence::Sequence(Array<SpAction> const& actions)
|
||||
Sequence::Sequence(Array<ActionPtr> const& actions)
|
||||
: action_index_(0)
|
||||
{
|
||||
this->Add(actions);
|
||||
|
|
@ -172,7 +172,7 @@ namespace easy2d
|
|||
action_index_ = 0;
|
||||
}
|
||||
|
||||
void Sequence::Add(SpAction const& action)
|
||||
void Sequence::Add(ActionPtr const& action)
|
||||
{
|
||||
if (action)
|
||||
{
|
||||
|
|
@ -180,7 +180,7 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
void Sequence::Add(Array<SpAction> const& actions)
|
||||
void Sequence::Add(Array<ActionPtr> const& actions)
|
||||
{
|
||||
for (const auto &action : actions)
|
||||
{
|
||||
|
|
@ -188,7 +188,7 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
SpAction Sequence::Clone() const
|
||||
ActionPtr Sequence::Clone() const
|
||||
{
|
||||
auto sequence = new (std::nothrow) Sequence();
|
||||
if (sequence)
|
||||
|
|
@ -204,7 +204,7 @@ namespace easy2d
|
|||
return sequence;
|
||||
}
|
||||
|
||||
SpAction Sequence::Reverse() const
|
||||
ActionPtr Sequence::Reverse() const
|
||||
{
|
||||
auto sequence = new (std::nothrow) Sequence();
|
||||
if (sequence && !actions_.empty())
|
||||
|
|
@ -227,7 +227,7 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
Spawn::Spawn(Array<SpAction> const& actions)
|
||||
Spawn::Spawn(Array<ActionPtr> const& actions)
|
||||
{
|
||||
this->Add(actions);
|
||||
}
|
||||
|
|
@ -281,7 +281,7 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
void Spawn::Add(SpAction const& action)
|
||||
void Spawn::Add(ActionPtr const& action)
|
||||
{
|
||||
if (action)
|
||||
{
|
||||
|
|
@ -289,7 +289,7 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
void Spawn::Add(Array<SpAction> const& actions)
|
||||
void Spawn::Add(Array<ActionPtr> const& actions)
|
||||
{
|
||||
for (const auto &action : actions)
|
||||
{
|
||||
|
|
@ -297,7 +297,7 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
SpAction Spawn::Clone() const
|
||||
ActionPtr Spawn::Clone() const
|
||||
{
|
||||
auto spawn = new (std::nothrow) Spawn();
|
||||
if (spawn)
|
||||
|
|
@ -313,7 +313,7 @@ namespace easy2d
|
|||
return spawn;
|
||||
}
|
||||
|
||||
SpAction Spawn::Reverse() const
|
||||
ActionPtr Spawn::Reverse() const
|
||||
{
|
||||
auto spawn = new (std::nothrow) Spawn();
|
||||
if (spawn && !actions_.empty())
|
||||
|
|
|
|||
|
|
@ -29,17 +29,17 @@ namespace easy2d
|
|||
{
|
||||
public:
|
||||
explicit Loop(
|
||||
SpAction const& action, /* 执行循环的动作 */
|
||||
ActionPtr const& action, /* 执行循环的动作 */
|
||||
int times = -1 /* 循环次数 */
|
||||
);
|
||||
|
||||
virtual ~Loop();
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual SpAction Clone() const override;
|
||||
virtual ActionPtr Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual SpAction Reverse() const override;
|
||||
virtual ActionPtr Reverse() const override;
|
||||
|
||||
// 重置动作
|
||||
virtual void Reset() override;
|
||||
|
|
@ -54,7 +54,7 @@ namespace easy2d
|
|||
virtual void Update(Node* target, Duration const& dt) override;
|
||||
|
||||
protected:
|
||||
SpAction action_;
|
||||
ActionPtr action_;
|
||||
int times_;
|
||||
int total_times_;
|
||||
};
|
||||
|
|
@ -68,26 +68,26 @@ namespace easy2d
|
|||
Sequence();
|
||||
|
||||
explicit Sequence(
|
||||
Array<SpAction> const& actions /* 动作列表 */
|
||||
Array<ActionPtr> const& actions /* 动作列表 */
|
||||
);
|
||||
|
||||
virtual ~Sequence();
|
||||
|
||||
// 在结尾添加动作
|
||||
void Add(
|
||||
SpAction const& action
|
||||
ActionPtr const& action
|
||||
);
|
||||
|
||||
// 在结尾添加多个动作
|
||||
void Add(
|
||||
Array<SpAction> const& actions /* 动作列表 */
|
||||
Array<ActionPtr> const& actions /* 动作列表 */
|
||||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual SpAction Clone() const override;
|
||||
virtual ActionPtr Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual SpAction Reverse() const override;
|
||||
virtual ActionPtr Reverse() const override;
|
||||
|
||||
// 重置动作
|
||||
virtual void Reset() override;
|
||||
|
|
@ -101,7 +101,7 @@ namespace easy2d
|
|||
|
||||
protected:
|
||||
UINT action_index_;
|
||||
Array<SpAction> actions_;
|
||||
Array<ActionPtr> actions_;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -113,26 +113,26 @@ namespace easy2d
|
|||
Spawn();
|
||||
|
||||
explicit Spawn(
|
||||
Array<SpAction> const& actions /* 动作列表 */
|
||||
Array<ActionPtr> const& actions /* 动作列表 */
|
||||
);
|
||||
|
||||
virtual ~Spawn();
|
||||
|
||||
// 在结尾添加动作
|
||||
void Add(
|
||||
SpAction const& action
|
||||
ActionPtr const& action
|
||||
);
|
||||
|
||||
// 在结尾添加多个动作
|
||||
void Add(
|
||||
Array<SpAction> const& actions /* 动作列表 */
|
||||
Array<ActionPtr> const& actions /* 动作列表 */
|
||||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual SpAction Clone() const override;
|
||||
virtual ActionPtr Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual SpAction Reverse() const;
|
||||
virtual ActionPtr Reverse() const;
|
||||
|
||||
// 重置动作
|
||||
virtual void Reset() override;
|
||||
|
|
@ -145,6 +145,6 @@ namespace easy2d
|
|||
virtual void Update(Node* target, Duration const& dt) override;
|
||||
|
||||
protected:
|
||||
Array<SpAction> actions_;
|
||||
Array<ActionPtr> actions_;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ namespace easy2d
|
|||
if (actions_.IsEmpty())
|
||||
return;
|
||||
|
||||
SpAction next;
|
||||
ActionPtr next;
|
||||
for (auto action = actions_.First(); action; action = next)
|
||||
{
|
||||
next = action->NextItem();
|
||||
|
|
@ -41,7 +41,7 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
void ActionManager::AddAction(SpAction const& action)
|
||||
void ActionManager::AddAction(ActionPtr const& action)
|
||||
{
|
||||
E2D_ASSERT(action && "AddAction failed, NULL pointer exception");
|
||||
|
||||
|
|
|
|||
|
|
@ -25,12 +25,12 @@ namespace easy2d
|
|||
{
|
||||
class ActionManager
|
||||
{
|
||||
using Actions = intrusive::List<SpAction>;
|
||||
using Actions = intrusive::List<ActionPtr>;
|
||||
|
||||
public:
|
||||
// 执行动作
|
||||
void AddAction(
|
||||
SpAction const& action
|
||||
ActionPtr const& action
|
||||
);
|
||||
|
||||
// 继续所有暂停动作
|
||||
|
|
|
|||
|
|
@ -235,12 +235,12 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
SpAction MoveBy::Clone() const
|
||||
ActionPtr MoveBy::Clone() const
|
||||
{
|
||||
return new (std::nothrow) MoveBy(duration_, delta_pos_, ease_type_);
|
||||
}
|
||||
|
||||
SpAction MoveBy::Reverse() const
|
||||
ActionPtr MoveBy::Reverse() const
|
||||
{
|
||||
return new (std::nothrow) MoveBy(duration_, -delta_pos_, ease_type_);
|
||||
}
|
||||
|
|
@ -251,7 +251,7 @@ namespace easy2d
|
|||
end_pos_ = pos;
|
||||
}
|
||||
|
||||
SpAction MoveTo::Clone() const
|
||||
ActionPtr MoveTo::Clone() const
|
||||
{
|
||||
return new (std::nothrow) MoveTo(duration_, end_pos_, ease_type_);
|
||||
}
|
||||
|
|
@ -275,12 +275,12 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
SpAction JumpBy::Clone() const
|
||||
ActionPtr JumpBy::Clone() const
|
||||
{
|
||||
return new (std::nothrow) JumpBy(duration_, delta_pos_, height_, jumps_, ease_type_);
|
||||
}
|
||||
|
||||
SpAction JumpBy::Reverse() const
|
||||
ActionPtr JumpBy::Reverse() const
|
||||
{
|
||||
return new (std::nothrow) JumpBy(duration_, -delta_pos_, height_, jumps_, ease_type_);
|
||||
}
|
||||
|
|
@ -320,7 +320,7 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
SpAction JumpTo::Clone() const
|
||||
ActionPtr JumpTo::Clone() const
|
||||
{
|
||||
return new (std::nothrow) JumpTo(duration_, end_pos_, height_, jumps_, ease_type_);
|
||||
}
|
||||
|
|
@ -369,12 +369,12 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
SpAction ScaleBy::Clone() const
|
||||
ActionPtr ScaleBy::Clone() const
|
||||
{
|
||||
return new (std::nothrow) ScaleBy(duration_, delta_x_, delta_y_, ease_type_);
|
||||
}
|
||||
|
||||
SpAction ScaleBy::Reverse() const
|
||||
ActionPtr ScaleBy::Reverse() const
|
||||
{
|
||||
return new (std::nothrow) ScaleBy(duration_, -delta_x_, -delta_y_, ease_type_);
|
||||
}
|
||||
|
|
@ -393,7 +393,7 @@ namespace easy2d
|
|||
end_scale_y_ = scale_y;
|
||||
}
|
||||
|
||||
SpAction ScaleTo::Clone() const
|
||||
ActionPtr ScaleTo::Clone() const
|
||||
{
|
||||
return new (std::nothrow) ScaleTo(duration_, end_scale_x_, end_scale_y_, ease_type_);
|
||||
}
|
||||
|
|
@ -434,12 +434,12 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
SpAction OpacityBy::Clone() const
|
||||
ActionPtr OpacityBy::Clone() const
|
||||
{
|
||||
return new (std::nothrow) OpacityBy(duration_, delta_val_, ease_type_);
|
||||
}
|
||||
|
||||
SpAction OpacityBy::Reverse() const
|
||||
ActionPtr OpacityBy::Reverse() const
|
||||
{
|
||||
return new (std::nothrow) OpacityBy(duration_, -delta_val_, ease_type_);
|
||||
}
|
||||
|
|
@ -450,7 +450,7 @@ namespace easy2d
|
|||
end_val_ = opacity;
|
||||
}
|
||||
|
||||
SpAction OpacityTo::Clone() const
|
||||
ActionPtr OpacityTo::Clone() const
|
||||
{
|
||||
return new (std::nothrow) OpacityTo(duration_, end_val_, ease_type_);
|
||||
}
|
||||
|
|
@ -500,12 +500,12 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
SpAction RotateBy::Clone() const
|
||||
ActionPtr RotateBy::Clone() const
|
||||
{
|
||||
return new (std::nothrow) RotateBy(duration_, delta_val_, ease_type_);
|
||||
}
|
||||
|
||||
SpAction RotateBy::Reverse() const
|
||||
ActionPtr RotateBy::Reverse() const
|
||||
{
|
||||
return new (std::nothrow) RotateBy(duration_, -delta_val_, ease_type_);
|
||||
}
|
||||
|
|
@ -516,7 +516,7 @@ namespace easy2d
|
|||
end_val_ = rotation;
|
||||
}
|
||||
|
||||
SpAction RotateTo::Clone() const
|
||||
ActionPtr RotateTo::Clone() const
|
||||
{
|
||||
return new (std::nothrow) RotateTo(duration_, end_val_, ease_type_);
|
||||
}
|
||||
|
|
@ -532,7 +532,7 @@ namespace easy2d
|
|||
// PathAction
|
||||
//-------------------------------------------------------
|
||||
|
||||
PathAction::PathAction(Duration const & duration, SpGeometry const& geo, bool rotating, float start, float end, EaseFunc func)
|
||||
PathAction::PathAction(Duration const & duration, GeometryPtr const& geo, bool rotating, float start, float end, EaseFunc func)
|
||||
: Tween(duration, func)
|
||||
, start_(start)
|
||||
, end_(end)
|
||||
|
|
@ -541,12 +541,12 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
SpAction PathAction::Clone() const
|
||||
ActionPtr PathAction::Clone() const
|
||||
{
|
||||
return new PathAction(duration_, geo_, rotating_, start_, end_, ease_type_);
|
||||
}
|
||||
|
||||
SpAction PathAction::Reverse() const
|
||||
ActionPtr PathAction::Reverse() const
|
||||
{
|
||||
return new PathAction(duration_, geo_, rotating_, end_, start_, ease_type_);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,10 +128,10 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual SpAction Clone() const override;
|
||||
virtual ActionPtr Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual SpAction Reverse() const override;
|
||||
virtual ActionPtr Reverse() const override;
|
||||
|
||||
protected:
|
||||
virtual void Init(Node* target) override;
|
||||
|
|
@ -157,12 +157,12 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual SpAction Clone() const override;
|
||||
virtual ActionPtr Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual SpAction Reverse() const override
|
||||
virtual ActionPtr Reverse() const override
|
||||
{
|
||||
logs::Errorln("Reverse() not supported in MoveTo");
|
||||
logs::Errorln(L"Reverse() not supported in MoveTo");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
@ -188,10 +188,10 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual SpAction Clone() const override;
|
||||
virtual ActionPtr Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual SpAction Reverse() const override;
|
||||
virtual ActionPtr Reverse() const override;
|
||||
|
||||
protected:
|
||||
virtual void Init(Node* target) override;
|
||||
|
|
@ -221,12 +221,12 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual SpAction Clone() const override;
|
||||
virtual ActionPtr Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual SpAction Reverse() const override
|
||||
virtual ActionPtr Reverse() const override
|
||||
{
|
||||
logs::Errorln("Reverse() not supported in JumpTo");
|
||||
logs::Errorln(L"Reverse() not supported in JumpTo");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
@ -257,10 +257,10 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual SpAction Clone() const override;
|
||||
virtual ActionPtr Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual SpAction Reverse() const override;
|
||||
virtual ActionPtr Reverse() const override;
|
||||
|
||||
protected:
|
||||
virtual void Init(Node* target) override;
|
||||
|
|
@ -294,12 +294,12 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual SpAction Clone() const override;
|
||||
virtual ActionPtr Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual SpAction Reverse() const override
|
||||
virtual ActionPtr Reverse() const override
|
||||
{
|
||||
logs::Errorln("Reverse() not supported in ScaleTo");
|
||||
logs::Errorln(L"Reverse() not supported in ScaleTo");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
@ -324,10 +324,10 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual SpAction Clone() const override;
|
||||
virtual ActionPtr Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual SpAction Reverse() const override;
|
||||
virtual ActionPtr Reverse() const override;
|
||||
|
||||
protected:
|
||||
virtual void Init(Node* target) override;
|
||||
|
|
@ -352,12 +352,12 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual SpAction Clone() const override;
|
||||
virtual ActionPtr Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual SpAction Reverse() const override
|
||||
virtual ActionPtr Reverse() const override
|
||||
{
|
||||
logs::Errorln("Reverse() not supported in OpacityTo");
|
||||
logs::Errorln(L"Reverse() not supported in OpacityTo");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
@ -407,10 +407,10 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual SpAction Clone() const override;
|
||||
virtual ActionPtr Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual SpAction Reverse() const override;
|
||||
virtual ActionPtr Reverse() const override;
|
||||
|
||||
protected:
|
||||
virtual void Init(Node* target) override;
|
||||
|
|
@ -435,12 +435,12 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual SpAction Clone() const override;
|
||||
virtual ActionPtr Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual SpAction Reverse() const override
|
||||
virtual ActionPtr Reverse() const override
|
||||
{
|
||||
logs::Errorln("Reverse() not supported in RotateTo");
|
||||
logs::Errorln(L"Reverse() not supported in RotateTo");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
@ -459,7 +459,7 @@ namespace easy2d
|
|||
public:
|
||||
explicit PathAction(
|
||||
Duration const& duration, /* 持续时长 */
|
||||
SpGeometry const& geo, /* ¼¸ºÎͼÐÎ */
|
||||
GeometryPtr const& geo, /* ¼¸ºÎͼÐÎ */
|
||||
bool rotating = false, /* 沿路径切线方向旋转 */
|
||||
float start = 0.f, /* 起点 */
|
||||
float end = 1.f, /* 终点 */
|
||||
|
|
@ -467,10 +467,10 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual SpAction Clone() const override;
|
||||
virtual ActionPtr Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual SpAction Reverse() const override;
|
||||
virtual ActionPtr Reverse() const override;
|
||||
|
||||
protected:
|
||||
virtual void Init(Node* target) override;
|
||||
|
|
@ -482,6 +482,6 @@ namespace easy2d
|
|||
float start_;
|
||||
float end_;
|
||||
Point start_pos_;
|
||||
SpGeometry geo_;
|
||||
GeometryPtr geo_;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
Animation::Animation(SpFrames const& animation)
|
||||
Animation::Animation(FramesPtr const& animation)
|
||||
: frame_index_(0)
|
||||
, frames_(nullptr)
|
||||
{
|
||||
|
|
@ -42,12 +42,12 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
SpFrames Animation::GetAnimation() const
|
||||
FramesPtr Animation::GetAnimation() const
|
||||
{
|
||||
return frames_;
|
||||
}
|
||||
|
||||
void Animation::SetAnimation(SpFrames const& animation)
|
||||
void Animation::SetAnimation(FramesPtr const& animation)
|
||||
{
|
||||
if (animation && animation != frames_)
|
||||
{
|
||||
|
|
@ -106,7 +106,7 @@ namespace easy2d
|
|||
frame_index_ = 0;
|
||||
}
|
||||
|
||||
SpAction Animation::Clone() const
|
||||
ActionPtr Animation::Clone() const
|
||||
{
|
||||
if (frames_)
|
||||
{
|
||||
|
|
@ -115,7 +115,7 @@ namespace easy2d
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
SpAction Animation::Reverse() const
|
||||
ActionPtr Animation::Reverse() const
|
||||
{
|
||||
if (frames_)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -31,24 +31,24 @@ namespace easy2d
|
|||
Animation();
|
||||
|
||||
explicit Animation(
|
||||
SpFrames const& animation
|
||||
FramesPtr const& animation
|
||||
);
|
||||
|
||||
virtual ~Animation();
|
||||
|
||||
// 获取动画
|
||||
SpFrames GetAnimation() const;
|
||||
FramesPtr GetAnimation() const;
|
||||
|
||||
// 设置动画
|
||||
void SetAnimation(
|
||||
SpFrames const& animation
|
||||
FramesPtr const& animation
|
||||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual SpAction Clone() const override;
|
||||
virtual ActionPtr Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual SpAction Reverse() const override;
|
||||
virtual ActionPtr Reverse() const override;
|
||||
|
||||
// 重置动作
|
||||
virtual void Reset() override;
|
||||
|
|
@ -63,6 +63,6 @@ namespace easy2d
|
|||
protected:
|
||||
size_t frame_index_;
|
||||
Duration delta_;
|
||||
SpFrames frames_;
|
||||
FramesPtr frames_;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@ namespace easy2d
|
|||
cache_expired_ = true;
|
||||
}
|
||||
|
||||
void Canvas::DrawImage(SpImage const & image, float opacity)
|
||||
void Canvas::DrawImage(ImagePtr const & image, float opacity)
|
||||
{
|
||||
if (image && image->GetBitmap())
|
||||
{
|
||||
|
|
@ -267,7 +267,7 @@ namespace easy2d
|
|||
if (text.empty())
|
||||
return;
|
||||
|
||||
CpTextFormat text_format;
|
||||
D2DTextFormatPtr text_format;
|
||||
ThrowIfFailed(
|
||||
Factory::Instance()->CreateTextFormat(
|
||||
text_format,
|
||||
|
|
@ -276,7 +276,7 @@ namespace easy2d
|
|||
)
|
||||
);
|
||||
|
||||
CpTextLayout text_layout;
|
||||
D2DTextLayoutPtr text_layout;
|
||||
Size layout_size;
|
||||
ThrowIfFailed(
|
||||
Factory::Instance()->CreateTextLayout(
|
||||
|
|
@ -293,7 +293,7 @@ namespace easy2d
|
|||
);
|
||||
}
|
||||
|
||||
void Canvas::DrawGeometry(SpGeometry const & geo)
|
||||
void Canvas::DrawGeometry(GeometryPtr const & geo)
|
||||
{
|
||||
if (geo && geo->geo_)
|
||||
{
|
||||
|
|
@ -371,7 +371,7 @@ namespace easy2d
|
|||
cache_expired_ = true;
|
||||
}
|
||||
|
||||
void Canvas::FillGeometry(SpGeometry const & geo)
|
||||
void Canvas::FillGeometry(GeometryPtr const & geo)
|
||||
{
|
||||
if (geo && geo->geo_)
|
||||
{
|
||||
|
|
@ -493,14 +493,14 @@ namespace easy2d
|
|||
cache_expired_ = true;
|
||||
}
|
||||
|
||||
SpImage Canvas::ExportToImage() const
|
||||
ImagePtr Canvas::ExportToImage() const
|
||||
{
|
||||
auto image = new Image(GetBitmap());
|
||||
image->Crop(Rect(Point{}, this->GetSize()));
|
||||
return image;
|
||||
}
|
||||
|
||||
CpBitmap const& easy2d::Canvas::GetBitmap() const
|
||||
D2DBitmapPtr const& easy2d::Canvas::GetBitmap() const
|
||||
{
|
||||
if (cache_expired_)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ namespace easy2d
|
|||
|
||||
// 画图片
|
||||
void DrawImage(
|
||||
SpImage const& image,
|
||||
ImagePtr const& image,
|
||||
float opacity = 1.f
|
||||
);
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ namespace easy2d
|
|||
|
||||
// 画几何图形边框
|
||||
void DrawGeometry(
|
||||
SpGeometry const& geo
|
||||
GeometryPtr const& geo
|
||||
);
|
||||
|
||||
// 填充圆形
|
||||
|
|
@ -127,7 +127,7 @@ namespace easy2d
|
|||
|
||||
// 填充几何图形
|
||||
void FillGeometry(
|
||||
SpGeometry const& geo
|
||||
GeometryPtr const& geo
|
||||
);
|
||||
|
||||
// 开始绘制路径
|
||||
|
|
@ -216,26 +216,26 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 导出为图片
|
||||
SpImage ExportToImage() const;
|
||||
ImagePtr ExportToImage() const;
|
||||
|
||||
virtual void OnRender() override;
|
||||
|
||||
protected:
|
||||
CpBitmap const& GetBitmap() const;
|
||||
D2DBitmapPtr const& GetBitmap() const;
|
||||
|
||||
protected:
|
||||
mutable bool cache_expired_;
|
||||
mutable CpBitmap bitmap_cached_;
|
||||
mutable D2DBitmapPtr bitmap_cached_;
|
||||
float stroke_width_;
|
||||
Font text_font_;
|
||||
TextStyle text_style_;
|
||||
CpPathGeometry current_geometry_;
|
||||
CpGeometrySink current_sink_;
|
||||
CpStrokeStyle outline_join_style_;
|
||||
CpSolidColorBrush fill_brush_;
|
||||
CpSolidColorBrush stroke_brush_;
|
||||
CpSolidColorBrush text_brush_;
|
||||
CpTextRenderer text_renderer_;
|
||||
CpBitmapRenderTarget render_target_;
|
||||
D2DPathGeometryPtr current_geometry_;
|
||||
D2DGeometrySinkPtr current_sink_;
|
||||
D2DStrokeStylePtr outline_join_style_;
|
||||
D2DSolidColorBrushPtr fill_brush_;
|
||||
D2DSolidColorBrushPtr stroke_brush_;
|
||||
D2DSolidColorBrushPtr text_brush_;
|
||||
D2DTextRendererPtr text_renderer_;
|
||||
D2DBitmapRenderTargetPtr render_target_;
|
||||
};
|
||||
}
|
||||
|
|
@ -44,7 +44,7 @@ namespace easy2d
|
|||
void OnUpdate(Duration const& dt) override;
|
||||
|
||||
protected:
|
||||
SpText debug_text_;
|
||||
TextPtr debug_text_;
|
||||
Array<TimePoint> frame_time_;
|
||||
Array<String> texts_;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -51,12 +51,12 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
SpAction Delay::Clone() const
|
||||
ActionPtr Delay::Clone() const
|
||||
{
|
||||
return new (std::nothrow) Delay(delay_);
|
||||
}
|
||||
|
||||
SpAction Delay::Reverse() const
|
||||
ActionPtr Delay::Reverse() const
|
||||
{
|
||||
return new (std::nothrow) Delay(delay_);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,10 +33,10 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual SpAction Clone() const override;
|
||||
virtual ActionPtr Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual SpAction Reverse() const override;
|
||||
virtual ActionPtr Reverse() const override;
|
||||
|
||||
// 重置动作
|
||||
virtual void Reset() override;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ namespace easy2d
|
|||
if (listeners_.IsEmpty())
|
||||
return;
|
||||
|
||||
SpEventListener next;
|
||||
EventListenerPtr next;
|
||||
for (auto listener = listeners_.First(); listener; listener = next)
|
||||
{
|
||||
next = listener->NextItem();
|
||||
|
|
@ -40,7 +40,7 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
void EventDispatcher::AddListener(SpEventListener const & listener)
|
||||
void EventDispatcher::AddListener(EventListenerPtr const & listener)
|
||||
{
|
||||
E2D_ASSERT(listener && "AddListener failed, NULL pointer exception");
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ namespace easy2d
|
|||
|
||||
void EventDispatcher::AddListener(EventType type, EventCallback callback, String const& name)
|
||||
{
|
||||
SpEventListener listener = new EventListener(type, callback, name);
|
||||
EventListenerPtr listener = new EventListener(type, callback, name);
|
||||
if (listener)
|
||||
{
|
||||
listeners_.PushBack(listener);
|
||||
|
|
@ -83,7 +83,7 @@ namespace easy2d
|
|||
|
||||
void EventDispatcher::RemoveListeners(String const & listener_name)
|
||||
{
|
||||
SpEventListener next;
|
||||
EventListenerPtr next;
|
||||
for (auto listener = listeners_.First(); listener; listener = next)
|
||||
{
|
||||
next = listener->NextItem();
|
||||
|
|
@ -119,7 +119,7 @@ namespace easy2d
|
|||
|
||||
void EventDispatcher::RemoveListeners(EventType type)
|
||||
{
|
||||
SpEventListener next;
|
||||
EventListenerPtr next;
|
||||
for (auto listener = listeners_.First(); listener; listener = next)
|
||||
{
|
||||
next = listener->NextItem();
|
||||
|
|
|
|||
|
|
@ -25,12 +25,12 @@ namespace easy2d
|
|||
{
|
||||
class EventDispatcher
|
||||
{
|
||||
using Listeners = intrusive::List<SpEventListener>;
|
||||
using Listeners = intrusive::List<EventListenerPtr>;
|
||||
|
||||
public:
|
||||
// 添加监听器
|
||||
void AddListener(
|
||||
SpEventListener const& listener
|
||||
EventListenerPtr const& listener
|
||||
);
|
||||
|
||||
// 添加监听器
|
||||
|
|
|
|||
|
|
@ -32,10 +32,10 @@ namespace easy2d
|
|||
|
||||
class EventListener
|
||||
: public Object
|
||||
, protected intrusive::ListItem<SpEventListener>
|
||||
, protected intrusive::ListItem<EventListenerPtr>
|
||||
{
|
||||
friend class EventDispatcher;
|
||||
friend class intrusive::List<SpEventListener>;
|
||||
friend class intrusive::List<EventListenerPtr>;
|
||||
|
||||
public:
|
||||
EventListener(
|
||||
|
|
|
|||
|
|
@ -31,16 +31,16 @@ namespace easy2d
|
|||
|
||||
FactoryImpl::~FactoryImpl()
|
||||
{
|
||||
E2D_LOG("Destroying device independent resources");
|
||||
E2D_LOG(L"Destroying device independent resources");
|
||||
}
|
||||
|
||||
HRESULT FactoryImpl::Init(bool debug)
|
||||
{
|
||||
E2D_LOG("Creating device independent resources");
|
||||
E2D_LOG(L"Creating device independent resources");
|
||||
|
||||
D2D1_FACTORY_OPTIONS fact_options;
|
||||
fact_options.debugLevel = debug ? D2D1_DEBUG_LEVEL_INFORMATION : D2D1_DEBUG_LEVEL_NONE;
|
||||
HRESULT hr = modules::DirectX().D2D1CreateFactory(
|
||||
HRESULT hr = modules::DirectX::Get().D2D1CreateFactory(
|
||||
D2D1_FACTORY_TYPE_SINGLE_THREADED,
|
||||
__uuidof(ID2D1Factory),
|
||||
&fact_options,
|
||||
|
|
@ -60,7 +60,7 @@ namespace easy2d
|
|||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
modules::DirectX().DWriteCreateFactory(
|
||||
modules::DirectX::Get().DWriteCreateFactory(
|
||||
DWRITE_FACTORY_TYPE_SHARED,
|
||||
__uuidof(IDWriteFactory),
|
||||
reinterpret_cast<IUnknown**>(&write_factory_)
|
||||
|
|
@ -111,12 +111,12 @@ namespace easy2d
|
|||
return hr;
|
||||
}
|
||||
|
||||
HRESULT FactoryImpl::CreateHwndRenderTarget(CpHwndRenderTarget & hwnd_render_target, D2D1_RENDER_TARGET_PROPERTIES const & properties, D2D1_HWND_RENDER_TARGET_PROPERTIES const & hwnd_rt_properties) const
|
||||
HRESULT FactoryImpl::CreateHwndRenderTarget(D2DHwndRenderTargetPtr & hwnd_render_target, D2D1_RENDER_TARGET_PROPERTIES const & properties, D2D1_HWND_RENDER_TARGET_PROPERTIES const & hwnd_rt_properties) const
|
||||
{
|
||||
if (!factory_)
|
||||
return E_UNEXPECTED;
|
||||
|
||||
CpHwndRenderTarget hwnd_render_target_tmp;
|
||||
D2DHwndRenderTargetPtr hwnd_render_target_tmp;
|
||||
HRESULT hr = factory_->CreateHwndRenderTarget(
|
||||
properties,
|
||||
hwnd_rt_properties,
|
||||
|
|
@ -129,15 +129,15 @@ namespace easy2d
|
|||
}
|
||||
|
||||
HRESULT FactoryImpl::CreateTextRenderer(
|
||||
CpTextRenderer& text_renderer,
|
||||
CpRenderTarget const& render_target,
|
||||
CpSolidColorBrush const& brush
|
||||
D2DTextRendererPtr& text_renderer,
|
||||
D2DRenderTargetPtr const& render_target,
|
||||
D2DSolidColorBrushPtr const& brush
|
||||
)
|
||||
{
|
||||
if (!factory_)
|
||||
return E_UNEXPECTED;
|
||||
|
||||
CpTextRenderer text_renderer_tmp;
|
||||
D2DTextRendererPtr text_renderer_tmp;
|
||||
HRESULT hr = ITextRenderer::Create(
|
||||
&text_renderer_tmp,
|
||||
factory_.Get(),
|
||||
|
|
@ -150,7 +150,7 @@ namespace easy2d
|
|||
return hr;
|
||||
}
|
||||
|
||||
HRESULT FactoryImpl::CreateBitmapFromFile(CpBitmap & bitmap, CpRenderTarget const & rt, String const & file_path)
|
||||
HRESULT FactoryImpl::CreateBitmapFromFile(D2DBitmapPtr & bitmap, D2DRenderTargetPtr const & rt, String const & file_path)
|
||||
{
|
||||
if (imaging_factory_ == nullptr)
|
||||
{
|
||||
|
|
@ -159,11 +159,11 @@ namespace easy2d
|
|||
|
||||
using namespace intrusive;
|
||||
|
||||
SmartPointer<IWICBitmapDecoder> decoder;
|
||||
SmartPointer<IWICBitmapFrameDecode> source;
|
||||
SmartPointer<IWICStream> stream;
|
||||
SmartPointer<IWICFormatConverter> converter;
|
||||
SmartPointer<ID2D1Bitmap> bitmap_tmp;
|
||||
SmartPtr<IWICBitmapDecoder> decoder;
|
||||
SmartPtr<IWICBitmapFrameDecode> source;
|
||||
SmartPtr<IWICStream> stream;
|
||||
SmartPtr<IWICFormatConverter> converter;
|
||||
SmartPtr<ID2D1Bitmap> bitmap_tmp;
|
||||
|
||||
HRESULT hr = imaging_factory_->CreateDecoderFromFilename(
|
||||
file_path.c_str(),
|
||||
|
|
@ -211,7 +211,7 @@ namespace easy2d
|
|||
return hr;
|
||||
}
|
||||
|
||||
HRESULT FactoryImpl::CreateBitmapFromResource(CpBitmap & bitmap, CpRenderTarget const & rt, Resource const & res)
|
||||
HRESULT FactoryImpl::CreateBitmapFromResource(D2DBitmapPtr & bitmap, D2DRenderTargetPtr const & rt, Resource const & res)
|
||||
{
|
||||
if (imaging_factory_ == nullptr)
|
||||
{
|
||||
|
|
@ -220,11 +220,11 @@ namespace easy2d
|
|||
|
||||
using namespace intrusive;
|
||||
|
||||
SmartPointer<IWICBitmapDecoder> decoder;
|
||||
SmartPointer<IWICBitmapFrameDecode> source;
|
||||
SmartPointer<IWICStream> stream;
|
||||
SmartPointer<IWICFormatConverter> converter;
|
||||
SmartPointer<ID2D1Bitmap> bitmap_tmp;
|
||||
SmartPtr<IWICBitmapDecoder> decoder;
|
||||
SmartPtr<IWICBitmapFrameDecode> source;
|
||||
SmartPtr<IWICStream> stream;
|
||||
SmartPtr<IWICFormatConverter> converter;
|
||||
SmartPtr<ID2D1Bitmap> bitmap_tmp;
|
||||
|
||||
// ¼ÓÔØ×ÊÔ´
|
||||
LPVOID buffer;
|
||||
|
|
@ -294,12 +294,12 @@ namespace easy2d
|
|||
return hr;
|
||||
}
|
||||
|
||||
HRESULT FactoryImpl::CreateRectangleGeometry(CpRectangleGeometry & geo, Rect const& rect) const
|
||||
HRESULT FactoryImpl::CreateRectangleGeometry(D2DRectangleGeometryPtr & geo, Rect const& rect) const
|
||||
{
|
||||
if (!factory_)
|
||||
return E_UNEXPECTED;
|
||||
|
||||
CpRectangleGeometry rectangle;
|
||||
D2DRectangleGeometryPtr rectangle;
|
||||
HRESULT hr = factory_->CreateRectangleGeometry(
|
||||
rect,
|
||||
&rectangle
|
||||
|
|
@ -310,12 +310,12 @@ namespace easy2d
|
|||
return hr;
|
||||
}
|
||||
|
||||
HRESULT FactoryImpl::CreateRoundedRectangleGeometry(CpRoundedRectangleGeometry & geo, Rect const & rect, float radius_x, float radius_y) const
|
||||
HRESULT FactoryImpl::CreateRoundedRectangleGeometry(D2DRoundedRectangleGeometryPtr & geo, Rect const & rect, float radius_x, float radius_y) const
|
||||
{
|
||||
if (!factory_)
|
||||
return E_UNEXPECTED;
|
||||
|
||||
CpRoundedRectangleGeometry rounded_rect;
|
||||
D2DRoundedRectangleGeometryPtr rounded_rect;
|
||||
HRESULT hr = factory_->CreateRoundedRectangleGeometry(
|
||||
D2D1::RoundedRect(
|
||||
rect,
|
||||
|
|
@ -330,12 +330,12 @@ namespace easy2d
|
|||
return hr;
|
||||
}
|
||||
|
||||
HRESULT FactoryImpl::CreateEllipseGeometry(CpEllipseGeometry & geo, Point const & center, float radius_x, float radius_y) const
|
||||
HRESULT FactoryImpl::CreateEllipseGeometry(D2DEllipseGeometryPtr & geo, Point const & center, float radius_x, float radius_y) const
|
||||
{
|
||||
if (!factory_)
|
||||
return E_UNEXPECTED;
|
||||
|
||||
CpEllipseGeometry ellipse;
|
||||
D2DEllipseGeometryPtr ellipse;
|
||||
HRESULT hr = factory_->CreateEllipseGeometry(
|
||||
D2D1::Ellipse(
|
||||
center,
|
||||
|
|
@ -351,15 +351,15 @@ namespace easy2d
|
|||
}
|
||||
|
||||
HRESULT FactoryImpl::CreateTransformedGeometry(
|
||||
CpTransformedGeometry& transformed,
|
||||
D2DTransformedGeometryPtr& transformed,
|
||||
Matrix const& matrix,
|
||||
CpGeometry const& geo
|
||||
D2DGeometryPtr const& geo
|
||||
) const
|
||||
{
|
||||
if (!factory_)
|
||||
return E_UNEXPECTED;
|
||||
|
||||
CpTransformedGeometry transformed_tmp;
|
||||
D2DTransformedGeometryPtr transformed_tmp;
|
||||
HRESULT hr = factory_->CreateTransformedGeometry(
|
||||
geo.Get(),
|
||||
matrix,
|
||||
|
|
@ -373,7 +373,7 @@ namespace easy2d
|
|||
return hr;
|
||||
}
|
||||
|
||||
HRESULT FactoryImpl::CreatePathGeometry(CpPathGeometry & geometry) const
|
||||
HRESULT FactoryImpl::CreatePathGeometry(D2DPathGeometryPtr & geometry) const
|
||||
{
|
||||
if (!factory_)
|
||||
return E_UNEXPECTED;
|
||||
|
|
@ -381,12 +381,12 @@ namespace easy2d
|
|||
return factory_->CreatePathGeometry(&geometry);
|
||||
}
|
||||
|
||||
HRESULT FactoryImpl::CreateTextFormat(CpTextFormat & text_format, Font const & font, TextStyle const & text_style) const
|
||||
HRESULT FactoryImpl::CreateTextFormat(D2DTextFormatPtr & text_format, Font const & font, TextStyle const & text_style) const
|
||||
{
|
||||
if (!write_factory_)
|
||||
return E_UNEXPECTED;
|
||||
|
||||
CpTextFormat text_format_tmp;
|
||||
D2DTextFormatPtr text_format_tmp;
|
||||
HRESULT hr = write_factory_->CreateTextFormat(
|
||||
font.family.c_str(),
|
||||
nullptr,
|
||||
|
|
@ -419,7 +419,7 @@ namespace easy2d
|
|||
return hr;
|
||||
}
|
||||
|
||||
HRESULT FactoryImpl::CreateTextLayout(CpTextLayout & text_layout, Size& layout_size, String const & text, CpTextFormat const& text_format, TextStyle const & text_style) const
|
||||
HRESULT FactoryImpl::CreateTextLayout(D2DTextLayoutPtr & text_layout, Size& layout_size, String const & text, D2DTextFormatPtr const& text_format, TextStyle const & text_style) const
|
||||
{
|
||||
if (!write_factory_)
|
||||
return E_UNEXPECTED;
|
||||
|
|
@ -427,7 +427,7 @@ namespace easy2d
|
|||
text_layout = nullptr;
|
||||
|
||||
HRESULT hr;
|
||||
CpTextLayout text_layout_tmp;
|
||||
D2DTextLayoutPtr text_layout_tmp;
|
||||
UINT32 length = static_cast<UINT32>(text.length());
|
||||
|
||||
if (text_style.wrap)
|
||||
|
|
@ -497,7 +497,7 @@ namespace easy2d
|
|||
return hr;
|
||||
}
|
||||
|
||||
CpStrokeStyle const& FactoryImpl::GetStrokeStyle(StrokeStyle stroke) const
|
||||
D2DStrokeStylePtr const& FactoryImpl::GetStrokeStyle(StrokeStyle stroke) const
|
||||
{
|
||||
switch (stroke)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -38,73 +38,73 @@ namespace easy2d
|
|||
HRESULT Init(bool debug);
|
||||
|
||||
HRESULT CreateHwndRenderTarget(
|
||||
CpHwndRenderTarget& hwnd_render_target,
|
||||
D2DHwndRenderTargetPtr& hwnd_render_target,
|
||||
D2D1_RENDER_TARGET_PROPERTIES const& properties,
|
||||
D2D1_HWND_RENDER_TARGET_PROPERTIES const& hwnd_rt_properties
|
||||
) const;
|
||||
|
||||
HRESULT CreateTextRenderer(
|
||||
CpTextRenderer& text_renderer,
|
||||
CpRenderTarget const& render_target,
|
||||
CpSolidColorBrush const& brush
|
||||
D2DTextRendererPtr& text_renderer,
|
||||
D2DRenderTargetPtr const& render_target,
|
||||
D2DSolidColorBrushPtr const& brush
|
||||
);
|
||||
|
||||
HRESULT CreateBitmapFromFile(
|
||||
CpBitmap& bitmap,
|
||||
CpRenderTarget const& rt,
|
||||
D2DBitmapPtr& bitmap,
|
||||
D2DRenderTargetPtr const& rt,
|
||||
String const& file_path
|
||||
);
|
||||
|
||||
HRESULT CreateBitmapFromResource(
|
||||
CpBitmap& bitmap,
|
||||
CpRenderTarget const& rt,
|
||||
D2DBitmapPtr& bitmap,
|
||||
D2DRenderTargetPtr const& rt,
|
||||
Resource const& res
|
||||
);
|
||||
|
||||
HRESULT CreateRectangleGeometry(
|
||||
CpRectangleGeometry& geo,
|
||||
D2DRectangleGeometryPtr& geo,
|
||||
Rect const& rect
|
||||
) const;
|
||||
|
||||
HRESULT CreateRoundedRectangleGeometry(
|
||||
CpRoundedRectangleGeometry& geo,
|
||||
D2DRoundedRectangleGeometryPtr& geo,
|
||||
Rect const& rect,
|
||||
float radius_x,
|
||||
float radius_y
|
||||
) const;
|
||||
|
||||
HRESULT CreateEllipseGeometry(
|
||||
CpEllipseGeometry& geo,
|
||||
D2DEllipseGeometryPtr& geo,
|
||||
Point const& center,
|
||||
float radius_x,
|
||||
float radius_y
|
||||
) const;
|
||||
|
||||
HRESULT CreateTransformedGeometry(
|
||||
CpTransformedGeometry& transformed,
|
||||
D2DTransformedGeometryPtr& transformed,
|
||||
Matrix const& matrix,
|
||||
CpGeometry const& geo
|
||||
D2DGeometryPtr const& geo
|
||||
) const;
|
||||
|
||||
HRESULT CreatePathGeometry(
|
||||
CpPathGeometry& geometry
|
||||
D2DPathGeometryPtr& geometry
|
||||
) const;
|
||||
|
||||
HRESULT CreateTextFormat(
|
||||
CpTextFormat& text_format,
|
||||
D2DTextFormatPtr& text_format,
|
||||
Font const& font,
|
||||
TextStyle const& text_style
|
||||
) const;
|
||||
|
||||
HRESULT CreateTextLayout(
|
||||
CpTextLayout& text_layout,
|
||||
D2DTextLayoutPtr& text_layout,
|
||||
Size& layout_size,
|
||||
String const& text,
|
||||
CpTextFormat const& text_format,
|
||||
D2DTextFormatPtr const& text_format,
|
||||
TextStyle const& text_style
|
||||
) const;
|
||||
|
||||
CpStrokeStyle const& GetStrokeStyle(
|
||||
D2DStrokeStylePtr const& GetStrokeStyle(
|
||||
StrokeStyle stroke
|
||||
) const;
|
||||
|
||||
|
|
@ -114,12 +114,12 @@ namespace easy2d
|
|||
~FactoryImpl();
|
||||
|
||||
protected:
|
||||
CpFactory factory_;
|
||||
CpImagingFactory imaging_factory_;
|
||||
CpWriteFactory write_factory_;
|
||||
CpStrokeStyle miter_stroke_style_;
|
||||
CpStrokeStyle bevel_stroke_style_;
|
||||
CpStrokeStyle round_stroke_style_;
|
||||
D2DFactoryPtr factory_;
|
||||
D2DImagingFactoryPtr imaging_factory_;
|
||||
D2DWriteFactoryPtr write_factory_;
|
||||
D2DStrokeStylePtr miter_stroke_style_;
|
||||
D2DStrokeStylePtr bevel_stroke_style_;
|
||||
D2DStrokeStylePtr round_stroke_style_;
|
||||
};
|
||||
|
||||
E2D_DECLARE_SINGLETON_TYPE(FactoryImpl, Factory);
|
||||
|
|
|
|||
|
|
@ -25,22 +25,17 @@
|
|||
namespace easy2d
|
||||
{
|
||||
Frames::Frames()
|
||||
: interval_(1)
|
||||
: interval_(200)
|
||||
{
|
||||
}
|
||||
|
||||
Frames::Frames(Array<SpImage> const& frames)
|
||||
: interval_(1)
|
||||
Frames::Frames(Array<ImagePtr> const& frames)
|
||||
: interval_(200)
|
||||
{
|
||||
this->Add(frames);
|
||||
}
|
||||
|
||||
Frames::Frames(Duration const& interval)
|
||||
: interval_(interval)
|
||||
{
|
||||
}
|
||||
|
||||
Frames::Frames(Duration const& interval, Array<SpImage> const& frames)
|
||||
Frames::Frames(Duration const& interval, Array<ImagePtr> const& frames)
|
||||
: interval_(interval)
|
||||
{
|
||||
this->Add(frames);
|
||||
|
|
@ -55,7 +50,7 @@ namespace easy2d
|
|||
interval_ = interval;
|
||||
}
|
||||
|
||||
void Frames::Add(SpImage const& frame)
|
||||
void Frames::Add(ImagePtr const& frame)
|
||||
{
|
||||
E2D_ASSERT(frame && "Frames::Add failed, NULL pointer exception");
|
||||
|
||||
|
|
@ -65,7 +60,7 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
void Frames::Add(Array<SpImage> const& frames)
|
||||
void Frames::Add(Array<ImagePtr> const& frames)
|
||||
{
|
||||
for (const auto &image : frames)
|
||||
{
|
||||
|
|
@ -78,16 +73,17 @@ namespace easy2d
|
|||
return interval_;
|
||||
}
|
||||
|
||||
Array<SpImage> const& Frames::GetFrames() const
|
||||
Array<ImagePtr> const& Frames::GetFrames() const
|
||||
{
|
||||
return frames_;
|
||||
}
|
||||
|
||||
SpFrames Frames::Clone() const
|
||||
FramesPtr Frames::Clone() const
|
||||
{
|
||||
auto animation = new (std::nothrow) Frames(interval_);
|
||||
auto animation = new (std::nothrow) Frames;
|
||||
if (animation)
|
||||
{
|
||||
animation->SetInterval(interval_);
|
||||
for (const auto& frame : frames_)
|
||||
{
|
||||
animation->Add(frame);
|
||||
|
|
@ -96,11 +92,12 @@ namespace easy2d
|
|||
return animation;
|
||||
}
|
||||
|
||||
SpFrames Frames::Reverse() const
|
||||
FramesPtr Frames::Reverse() const
|
||||
{
|
||||
auto animation = new (std::nothrow) Frames(interval_);
|
||||
auto animation = new (std::nothrow) Frames;
|
||||
if (!frames_.empty())
|
||||
{
|
||||
animation->SetInterval(interval_);
|
||||
for (auto iter = frames_.crbegin(), crend = frames_.crend(); iter != crend; ++iter)
|
||||
{
|
||||
if (*iter)
|
||||
|
|
|
|||
|
|
@ -32,35 +32,31 @@ namespace easy2d
|
|||
Frames();
|
||||
|
||||
explicit Frames(
|
||||
Array<SpImage> const& frames /* 关键帧数组 */
|
||||
);
|
||||
|
||||
explicit Frames(
|
||||
Duration const& interval /* 帧间隔 */
|
||||
Array<ImagePtr> const& frames /* 关键帧数组 */
|
||||
);
|
||||
|
||||
explicit Frames(
|
||||
Duration const& interval, /* 帧间隔 */
|
||||
Array<SpImage> const& frames /* 关键帧数组 */
|
||||
Array<ImagePtr> const& frames /* 关键帧数组 */
|
||||
);
|
||||
|
||||
virtual ~Frames();
|
||||
|
||||
// 添加关键帧
|
||||
void Add(
|
||||
SpImage const& frame
|
||||
ImagePtr const& frame
|
||||
);
|
||||
|
||||
// 添加多个关键帧
|
||||
void Add(
|
||||
Array<SpImage> const& frames
|
||||
Array<ImagePtr> const& frames
|
||||
);
|
||||
|
||||
// 获取帧间隔
|
||||
Duration const& GetInterval() const;
|
||||
|
||||
// 获取关键帧
|
||||
Array<SpImage> const& GetFrames() const;
|
||||
Array<ImagePtr> const& GetFrames() const;
|
||||
|
||||
// 设置每一帧的时间间隔
|
||||
void SetInterval(
|
||||
|
|
@ -68,13 +64,13 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取帧动画的拷贝对象
|
||||
SpFrames Clone() const;
|
||||
FramesPtr Clone() const;
|
||||
|
||||
// 获取帧动画的倒转
|
||||
SpFrames Reverse() const;
|
||||
FramesPtr Reverse() const;
|
||||
|
||||
protected:
|
||||
Duration interval_;
|
||||
Array<SpImage> frames_;
|
||||
Array<ImagePtr> frames_;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ namespace easy2d
|
|||
Window::Instance()->Destroy();
|
||||
}
|
||||
|
||||
void Game::EnterScene(SpScene const & scene)
|
||||
void Game::EnterScene(ScenePtr const & scene)
|
||||
{
|
||||
E2D_ASSERT(scene && "Game::EnterScene failed, NULL pointer exception");
|
||||
|
||||
|
|
@ -163,7 +163,7 @@ namespace easy2d
|
|||
next_scene_ = scene;
|
||||
}
|
||||
|
||||
void Game::EnterScene(SpScene const& scene, SpTransition const& transition)
|
||||
void Game::EnterScene(ScenePtr const& scene, TransitionPtr const& transition)
|
||||
{
|
||||
EnterScene(scene);
|
||||
|
||||
|
|
@ -178,7 +178,7 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
SpScene const& Game::GetCurrentScene()
|
||||
ScenePtr const& Game::GetCurrentScene()
|
||||
{
|
||||
return curr_scene_;
|
||||
}
|
||||
|
|
@ -337,7 +337,7 @@ namespace easy2d
|
|||
|
||||
case WM_DISPLAYCHANGE:
|
||||
{
|
||||
E2D_LOG("The display resolution has changed");
|
||||
E2D_LOG(L"The display resolution has changed");
|
||||
|
||||
::InvalidateRect(hwnd, nullptr, FALSE);
|
||||
}
|
||||
|
|
@ -345,7 +345,7 @@ namespace easy2d
|
|||
|
||||
case WM_CLOSE:
|
||||
{
|
||||
E2D_LOG("Received a message to close the window");
|
||||
E2D_LOG(L"Received a message to close the window");
|
||||
|
||||
SysEvent event(SysEvent::WindowClose);
|
||||
game->Dispatch(&event);
|
||||
|
|
@ -360,7 +360,7 @@ namespace easy2d
|
|||
|
||||
case WM_DESTROY:
|
||||
{
|
||||
E2D_LOG("Window was destroyed");
|
||||
E2D_LOG(L"Window was destroyed");
|
||||
|
||||
game->OnExit();
|
||||
::PostQuitMessage(0);
|
||||
|
|
@ -374,14 +374,14 @@ namespace easy2d
|
|||
{
|
||||
game->active_ = false;
|
||||
|
||||
E2D_LOG("Window minimized");
|
||||
E2D_LOG(L"Window minimized");
|
||||
}
|
||||
else if (SIZE_RESTORED == wparam)
|
||||
{
|
||||
game->active_ = true;
|
||||
::InvalidateRect(hwnd, nullptr, FALSE);
|
||||
|
||||
E2D_LOG("Window restored");
|
||||
E2D_LOG(L"Window restored");
|
||||
}
|
||||
|
||||
UINT width = LOWORD(lparam);
|
||||
|
|
@ -399,14 +399,14 @@ namespace easy2d
|
|||
bool active = (LOWORD(wparam) != WA_INACTIVE);
|
||||
if (active)
|
||||
{
|
||||
E2D_LOG("Window activated");
|
||||
E2D_LOG(L"Window activated");
|
||||
|
||||
SysEvent event(SysEvent::WindowActivate);
|
||||
game->Dispatch(&event);
|
||||
}
|
||||
else
|
||||
{
|
||||
E2D_LOG("Window deactivated");
|
||||
E2D_LOG(L"Window deactivated");
|
||||
|
||||
SysEvent event(SysEvent::WindowDeavtivate);
|
||||
game->Dispatch(&event);
|
||||
|
|
@ -416,13 +416,13 @@ namespace easy2d
|
|||
|
||||
case WM_SETTEXT:
|
||||
{
|
||||
E2D_LOG("Window title changed");
|
||||
E2D_LOG(L"Window title changed");
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_SETICON:
|
||||
{
|
||||
E2D_LOG("Window icon changed");
|
||||
E2D_LOG(L"Window icon changed");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,17 +80,17 @@ namespace easy2d
|
|||
|
||||
// Çл»³¡¾°
|
||||
void EnterScene(
|
||||
SpScene const& scene /* 场景 */
|
||||
ScenePtr const& scene /* 场景 */
|
||||
);
|
||||
|
||||
// Çл»³¡¾°
|
||||
void EnterScene(
|
||||
SpScene const& scene, /* 场景 */
|
||||
SpTransition const& transition /* 场景动画 */
|
||||
ScenePtr const& scene, /* 场景 */
|
||||
TransitionPtr const& transition /* 场景动画 */
|
||||
);
|
||||
|
||||
// »ñÈ¡µ±Ç°³¡¾°
|
||||
SpScene const& GetCurrentScene();
|
||||
ScenePtr const& GetCurrentScene();
|
||||
|
||||
// ÉèÖñäËÙ
|
||||
void SetTimeScale(float scale);
|
||||
|
|
@ -110,8 +110,8 @@ namespace easy2d
|
|||
bool debug_;
|
||||
bool active_;
|
||||
float time_scale_;
|
||||
SpScene curr_scene_;
|
||||
SpScene next_scene_;
|
||||
SpTransition transition_;
|
||||
ScenePtr curr_scene_;
|
||||
ScenePtr next_scene_;
|
||||
TransitionPtr transition_;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,8 +126,8 @@ namespace easy2d
|
|||
|
||||
void LineGeometry::SetLine(Point const & begin, Point const & end)
|
||||
{
|
||||
CpPathGeometry path_geo;
|
||||
CpGeometrySink path_sink;
|
||||
D2DPathGeometryPtr path_geo;
|
||||
D2DGeometrySinkPtr path_sink;
|
||||
|
||||
HRESULT hr = Factory::Instance()->CreatePathGeometry(path_geo);
|
||||
|
||||
|
|
@ -185,7 +185,7 @@ namespace easy2d
|
|||
|
||||
void RectangleGeometry::SetRect(Rect const & rect)
|
||||
{
|
||||
CpRectangleGeometry geo;
|
||||
D2DRectangleGeometryPtr geo;
|
||||
if (SUCCEEDED(Factory::Instance()->CreateRectangleGeometry(geo, rect)))
|
||||
{
|
||||
geo_ = geo;
|
||||
|
|
@ -224,7 +224,7 @@ namespace easy2d
|
|||
|
||||
void CircleGeometry::SetCircle(Point const & center, float radius)
|
||||
{
|
||||
CpEllipseGeometry geo;
|
||||
D2DEllipseGeometryPtr geo;
|
||||
if (SUCCEEDED(Factory::Instance()->CreateEllipseGeometry(geo, center, radius, radius)))
|
||||
{
|
||||
geo_ = geo;
|
||||
|
|
@ -265,7 +265,7 @@ namespace easy2d
|
|||
|
||||
void EllipseGeometry::SetEllipse(Point const & center, float radius_x, float radius_y)
|
||||
{
|
||||
CpEllipseGeometry geo;
|
||||
D2DEllipseGeometryPtr geo;
|
||||
if (SUCCEEDED(Factory::Instance()->CreateEllipseGeometry(geo, center, radius_x, radius_y)))
|
||||
{
|
||||
geo_ = geo;
|
||||
|
|
@ -414,7 +414,7 @@ namespace easy2d
|
|||
|
||||
void RoundedRectGeometry::SetRoundedRect(Rect const & rect, float radius_x, float radius_y)
|
||||
{
|
||||
CpRoundedRectangleGeometry geo;
|
||||
D2DRoundedRectangleGeometryPtr geo;
|
||||
if (SUCCEEDED(Factory::Instance()->CreateRoundedRectangleGeometry(geo, rect, radius_x, radius_y)))
|
||||
{
|
||||
geo_ = geo;
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ namespace easy2d
|
|||
float ComputeArea();
|
||||
|
||||
protected:
|
||||
CpGeometry geo_;
|
||||
D2DGeometryPtr geo_;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -254,8 +254,8 @@ namespace easy2d
|
|||
void ClearPath();
|
||||
|
||||
protected:
|
||||
CpPathGeometry current_geometry_;
|
||||
CpGeometrySink current_sink_;
|
||||
D2DPathGeometryPtr current_geometry_;
|
||||
D2DGeometrySinkPtr current_sink_;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
GeometryNode::GeometryNode(SpGeometry const& geometry)
|
||||
GeometryNode::GeometryNode(GeometryPtr const& geometry)
|
||||
: GeometryNode()
|
||||
{
|
||||
SetGeometry(geometry);
|
||||
|
|
@ -41,7 +41,7 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
void GeometryNode::SetGeometry(SpGeometry const& geometry)
|
||||
void GeometryNode::SetGeometry(GeometryPtr const& geometry)
|
||||
{
|
||||
geometry_ = geometry;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,14 +32,14 @@ namespace easy2d
|
|||
GeometryNode();
|
||||
|
||||
GeometryNode(
|
||||
SpGeometry const& geometry
|
||||
GeometryPtr const& geometry
|
||||
);
|
||||
|
||||
virtual ~GeometryNode();
|
||||
|
||||
// ÉčÖĂĐÎ×´
|
||||
void SetGeometry(
|
||||
SpGeometry const& geometry
|
||||
GeometryPtr const& geometry
|
||||
);
|
||||
|
||||
// ÉčÖĂĚîłäŃŐÉŤ
|
||||
|
|
@ -63,7 +63,7 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// ťńČĄĐÎ×´
|
||||
SpGeometry const& GetGeometry() const { return geometry_; }
|
||||
GeometryPtr const& GetGeometry() const { return geometry_; }
|
||||
|
||||
// ťńČĄĚîłäŃŐÉŤ
|
||||
Color GetFillColor() const { return fill_color_; }
|
||||
|
|
@ -84,6 +84,6 @@ namespace easy2d
|
|||
Color stroke_color_;
|
||||
float stroke_width_;
|
||||
StrokeStyle outline_join_;
|
||||
SpGeometry geometry_;
|
||||
GeometryPtr geometry_;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ namespace easy2d
|
|||
this->Crop(crop_rect);
|
||||
}
|
||||
|
||||
Image::Image(CpBitmap const & bitmap)
|
||||
Image::Image(D2DBitmapPtr const & bitmap)
|
||||
: Image()
|
||||
{
|
||||
SetBitmap(bitmap);
|
||||
|
|
@ -58,22 +58,16 @@ namespace easy2d
|
|||
bool Image::Load(Resource const& res)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
CpBitmap bitmap;
|
||||
D2DBitmapPtr bitmap;
|
||||
|
||||
if (res.IsFile())
|
||||
{
|
||||
File image_file;
|
||||
if (!image_file.Open(res.GetFileName()))
|
||||
if (!File(res.GetFileName()).Exists())
|
||||
{
|
||||
logs::Warningln("Image file '%s' not found!", StringWideCharToMultiByte(res.GetFileName()).c_str());
|
||||
logs::Warningln(L"Image file '%s' not found!", res.GetFileName());
|
||||
return false;
|
||||
}
|
||||
|
||||
// 用户输入的路径不一定是完整路径,因为用户可能通过 File::AddSearchPath 添加
|
||||
// 默认搜索路径,所以需要通过 File::GetPath 获取完整路径
|
||||
String image_file_path = image_file.GetPath();
|
||||
|
||||
hr = Graphics::Instance()->CreateBitmapFromFile(bitmap, image_file_path);
|
||||
hr = Graphics::Instance()->CreateBitmapFromFile(bitmap, res.GetFileName());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -82,7 +76,7 @@ namespace easy2d
|
|||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
logs::Errorln(hr, "Load image file failed!");
|
||||
logs::Errorln(hr, L"Load image file failed!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -165,12 +159,12 @@ namespace easy2d
|
|||
return crop_rect_;
|
||||
}
|
||||
|
||||
CpBitmap const& Image::GetBitmap() const
|
||||
D2DBitmapPtr const& Image::GetBitmap() const
|
||||
{
|
||||
return bitmap_;
|
||||
}
|
||||
|
||||
void Image::SetBitmap(CpBitmap const & bitmap)
|
||||
void Image::SetBitmap(D2DBitmapPtr const & bitmap)
|
||||
{
|
||||
if (bitmap)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ namespace easy2d
|
|||
);
|
||||
|
||||
explicit Image(
|
||||
CpBitmap const& bitmap
|
||||
D2DBitmapPtr const& bitmap
|
||||
);
|
||||
|
||||
virtual ~Image();
|
||||
|
|
@ -86,15 +86,15 @@ namespace easy2d
|
|||
// »ñÈ¡²Ã¼ô¾ØÐÎ
|
||||
Rect const& GetCropRect() const;
|
||||
|
||||
CpBitmap const& GetBitmap() const;
|
||||
D2DBitmapPtr const& GetBitmap() const;
|
||||
|
||||
protected:
|
||||
void SetBitmap(
|
||||
CpBitmap const& bitmap
|
||||
D2DBitmapPtr const& bitmap
|
||||
);
|
||||
|
||||
protected:
|
||||
Rect crop_rect_;
|
||||
CpBitmap bitmap_;
|
||||
D2DBitmapPtr bitmap_;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,12 +35,12 @@ namespace easy2d
|
|||
|
||||
InputDevice::~InputDevice()
|
||||
{
|
||||
E2D_LOG("Destroying input device");
|
||||
E2D_LOG(L"Destroying input device");
|
||||
}
|
||||
|
||||
HRESULT InputDevice::Init(HWND hwnd, float scale_x, float scale_y, bool debug)
|
||||
{
|
||||
E2D_LOG("Initing input device");
|
||||
E2D_LOG(L"Initing input device");
|
||||
|
||||
hwnd_ = hwnd;
|
||||
scale_x_ = scale_x;
|
||||
|
|
|
|||
|
|
@ -60,17 +60,12 @@ namespace easy2d
|
|||
|
||||
if (res.IsFile())
|
||||
{
|
||||
File music_file;
|
||||
if (!music_file.Open(res.GetFileName()))
|
||||
if (!File(res.GetFileName()).Exists())
|
||||
{
|
||||
logs::Warningln("Media file '%s' not found", StringWideCharToMultiByte(res.GetFileName()).c_str());
|
||||
logs::Warningln(L"Media file '%s' not found", res.GetFileName());
|
||||
return false;
|
||||
}
|
||||
|
||||
// 用户输入的路径不一定是完整路径,因为用户可能通过 File::AddSearchPath 添加
|
||||
// 默认搜索路径,所以需要通过 File::GetPath 获取完整路径
|
||||
String music_file_path = music_file.GetPath();
|
||||
HRESULT hr = transcoder.LoadMediaFile(music_file_path.c_str(), &wave_data_, &size_);
|
||||
hr = transcoder.LoadMediaFile(res.GetFileName(), &wave_data_, &size_);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -79,7 +74,7 @@ namespace easy2d
|
|||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
logs::Errorln(hr, "Load media file failed");
|
||||
logs::Errorln(hr, L"Load media file failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -91,7 +86,7 @@ namespace easy2d
|
|||
delete[] wave_data_;
|
||||
wave_data_ = nullptr;
|
||||
}
|
||||
logs::Errorln(hr, "Create source voice error");
|
||||
logs::Errorln(hr, L"Create source voice error");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -103,7 +98,7 @@ namespace easy2d
|
|||
{
|
||||
if (!opened_)
|
||||
{
|
||||
logs::Errorln("Music must be opened first!");
|
||||
logs::Errorln(L"Music must be opened first!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -120,7 +115,7 @@ namespace easy2d
|
|||
HRESULT hr = voice_.Play(wave_data_, size_, static_cast<UINT32>(loop_count));
|
||||
if (FAILED(hr))
|
||||
{
|
||||
logs::Errorln(hr, "Submitting source buffer error");
|
||||
logs::Errorln(hr, L"Submitting source buffer error");
|
||||
}
|
||||
|
||||
playing_ = SUCCEEDED(hr);
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ namespace easy2d
|
|||
|
||||
if (!children_.IsEmpty())
|
||||
{
|
||||
SpNode next;
|
||||
NodePtr next;
|
||||
for (auto child = children_.First(); child; child = next)
|
||||
{
|
||||
next = child->NextItem();
|
||||
|
|
@ -118,7 +118,7 @@ namespace easy2d
|
|||
if (!visible_)
|
||||
return;
|
||||
|
||||
SpNode prev;
|
||||
NodePtr prev;
|
||||
for (auto child = children_.Last(); child; child = prev)
|
||||
{
|
||||
prev = child->PrevItem();
|
||||
|
|
@ -255,7 +255,7 @@ namespace easy2d
|
|||
|
||||
if (parent_)
|
||||
{
|
||||
SpNode me = this;
|
||||
NodePtr me = this;
|
||||
|
||||
parent_->children_.Remove(me);
|
||||
|
||||
|
|
@ -272,7 +272,7 @@ namespace easy2d
|
|||
|
||||
if (sibling)
|
||||
{
|
||||
parent_->children_.InsertAfter(me, SpNode(sibling));
|
||||
parent_->children_.InsertAfter(me, NodePtr(sibling));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -444,7 +444,7 @@ namespace easy2d
|
|||
dirty_transform_ = true;
|
||||
}
|
||||
|
||||
void Node::AddChild(SpNode const& child)
|
||||
void Node::AddChild(NodePtr const& child)
|
||||
{
|
||||
E2D_ASSERT(child && "Node::AddChild failed, NULL pointer exception");
|
||||
|
||||
|
|
@ -453,11 +453,11 @@ namespace easy2d
|
|||
#ifdef E2D_DEBUG
|
||||
|
||||
if (child->parent_)
|
||||
logs::Errorln("The node to be added already has a parent");
|
||||
logs::Errorln(L"The node to be added already has a parent");
|
||||
|
||||
for (Node* parent = parent_; parent; parent = parent->parent_)
|
||||
if (parent == child)
|
||||
logs::Errorln("A node cannot be its own parent");
|
||||
logs::Errorln(L"A node cannot be its own parent");
|
||||
|
||||
#endif // E2D_DEBUG
|
||||
|
||||
|
|
@ -470,7 +470,7 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
void Node::AddChildren(Array<SpNode> const& children)
|
||||
void Node::AddChildren(Array<NodePtr> const& children)
|
||||
{
|
||||
for (const auto& node : children)
|
||||
{
|
||||
|
|
@ -483,9 +483,9 @@ namespace easy2d
|
|||
return Rect(Point{}, size_);
|
||||
}
|
||||
|
||||
Array<SpNode> Node::GetChildren(String const& name) const
|
||||
Array<NodePtr> Node::GetChildren(String const& name) const
|
||||
{
|
||||
Array<SpNode> children;
|
||||
Array<NodePtr> children;
|
||||
size_t hash_code = std::hash<String>{}(name);
|
||||
|
||||
for (Node* child = children_.First().Get(); child; child = child->NextItem().Get())
|
||||
|
|
@ -498,7 +498,7 @@ namespace easy2d
|
|||
return children;
|
||||
}
|
||||
|
||||
SpNode Node::GetChild(String const& name) const
|
||||
NodePtr Node::GetChild(String const& name) const
|
||||
{
|
||||
size_t hash_code = std::hash<String>{}(name);
|
||||
|
||||
|
|
@ -525,7 +525,7 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
bool Node::RemoveChild(SpNode const& child)
|
||||
bool Node::RemoveChild(NodePtr const& child)
|
||||
{
|
||||
return RemoveChild(child.Get());
|
||||
}
|
||||
|
|
@ -541,7 +541,7 @@ namespace easy2d
|
|||
{
|
||||
child->parent_ = nullptr;
|
||||
if (child->scene_) child->SetScene(nullptr);
|
||||
children_.Remove(SpNode(child));
|
||||
children_.Remove(NodePtr(child));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -37,14 +37,14 @@ namespace easy2d
|
|||
, public TaskManager
|
||||
, public ActionManager
|
||||
, public EventDispatcher
|
||||
, protected intrusive::ListItem<SpNode>
|
||||
, protected intrusive::ListItem<NodePtr>
|
||||
{
|
||||
friend class Game;
|
||||
friend class Scene;
|
||||
friend class Transition;
|
||||
friend class intrusive::List<SpNode>;
|
||||
friend class intrusive::List<NodePtr>;
|
||||
|
||||
using Children = intrusive::List<SpNode>;
|
||||
using Children = intrusive::List<NodePtr>;
|
||||
|
||||
public:
|
||||
Node();
|
||||
|
|
@ -291,21 +291,21 @@ namespace easy2d
|
|||
|
||||
// 添加子节点
|
||||
void AddChild(
|
||||
SpNode const& child
|
||||
NodePtr const& child
|
||||
);
|
||||
|
||||
// 添加多个子节点
|
||||
void AddChildren(
|
||||
Array<SpNode> const& children
|
||||
Array<NodePtr> const& children
|
||||
);
|
||||
|
||||
// 获取所有名称相同的子节点
|
||||
Array<SpNode> GetChildren(
|
||||
Array<NodePtr> GetChildren(
|
||||
String const& name
|
||||
) const;
|
||||
|
||||
// 获取名称相同的子节点
|
||||
SpNode GetChild(
|
||||
NodePtr GetChild(
|
||||
String const& name
|
||||
) const;
|
||||
|
||||
|
|
@ -314,7 +314,7 @@ namespace easy2d
|
|||
|
||||
// 移除子节点
|
||||
bool RemoveChild(
|
||||
SpNode const& child
|
||||
NodePtr const& child
|
||||
);
|
||||
|
||||
// 移除子节点
|
||||
|
|
|
|||
|
|
@ -23,12 +23,6 @@
|
|||
|
||||
namespace easy2d
|
||||
{
|
||||
Resource::Resource(String const& file_name)
|
||||
: type_(Type::File)
|
||||
, file_name_(file_name)
|
||||
{
|
||||
}
|
||||
|
||||
Resource::Resource(LPCWSTR file_name)
|
||||
: type_(Type::File)
|
||||
, file_name_(file_name)
|
||||
|
|
@ -42,14 +36,10 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
Resource::~Resource()
|
||||
{
|
||||
}
|
||||
|
||||
size_t Resource::GetHashCode() const
|
||||
{
|
||||
if (type_ == Type::File)
|
||||
return std::hash<String>{}(file_name_);
|
||||
return std::hash<LPCWSTR>{}(file_name_);
|
||||
return std::hash<LPCWSTR>{}(bin_name_);
|
||||
}
|
||||
|
||||
|
|
@ -64,28 +54,28 @@ namespace easy2d
|
|||
res_info = FindResourceW(nullptr, bin_name_, bin_type_);
|
||||
if (res_info == nullptr)
|
||||
{
|
||||
logs::Errorln("FindResource");
|
||||
logs::Errorln(L"FindResource");
|
||||
return false;
|
||||
}
|
||||
|
||||
res_data = LoadResource(nullptr, res_info);
|
||||
if (res_data == nullptr)
|
||||
{
|
||||
logs::Errorln("LoadResource");
|
||||
logs::Errorln(L"LoadResource");
|
||||
return false;
|
||||
}
|
||||
|
||||
buffer_size = SizeofResource(nullptr, res_info);
|
||||
if (buffer_size == 0)
|
||||
{
|
||||
logs::Errorln("SizeofResource");
|
||||
logs::Errorln(L"SizeofResource");
|
||||
return false;
|
||||
}
|
||||
|
||||
buffer = LockResource(res_data);
|
||||
if (buffer == nullptr)
|
||||
{
|
||||
logs::Errorln("LockResource");
|
||||
logs::Errorln(L"LockResource");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace easy2d
|
|||
{
|
||||
// 资源
|
||||
//
|
||||
// 资源可以是文件类型,也可以是保存在 exe 中的二进制文件
|
||||
// 资源可以是文件类型,也可以是保存在 exe 中的二进制资源
|
||||
// 例如, 一份音频资源的类型为 L"WAVE", 名称标识符为 IDR_WAVE_1,
|
||||
// 那么可以这样指定该资源: Resource res(MAKEINTRESOURCE(IDR_WAVE_1), L"WAVE");
|
||||
//
|
||||
|
|
@ -37,10 +37,6 @@ namespace easy2d
|
|||
public:
|
||||
enum class Type { File, Binary };
|
||||
|
||||
Resource(
|
||||
String const& file_name /* 文件路径 */
|
||||
);
|
||||
|
||||
Resource(
|
||||
LPCWSTR file_name /* 文件路径 */
|
||||
);
|
||||
|
|
@ -50,13 +46,11 @@ namespace easy2d
|
|||
LPCWSTR type /* 资源类型 */
|
||||
);
|
||||
|
||||
virtual ~Resource();
|
||||
|
||||
inline bool IsFile() const { return type_ == Type::File; }
|
||||
|
||||
inline Type GetType() const { return type_; }
|
||||
|
||||
inline String const& GetFileName() const { return file_name_; }
|
||||
inline LPCWSTR GetFileName() const { return file_name_; }
|
||||
|
||||
bool Load(
|
||||
LPVOID& buffer,
|
||||
|
|
@ -71,7 +65,7 @@ namespace easy2d
|
|||
{
|
||||
struct
|
||||
{
|
||||
String file_name_;
|
||||
LPCWSTR file_name_;
|
||||
};
|
||||
|
||||
struct
|
||||
|
|
|
|||
|
|
@ -38,12 +38,12 @@ namespace easy2d
|
|||
|
||||
void Scene::OnEnter()
|
||||
{
|
||||
E2D_LOG("Scene entered");
|
||||
E2D_LOG(L"Scene entered");
|
||||
}
|
||||
|
||||
void Scene::OnExit()
|
||||
{
|
||||
E2D_LOG("Scene exited");
|
||||
E2D_LOG(L"Scene exited");
|
||||
}
|
||||
|
||||
void Scene::OnDeactivate()
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
Sprite::Sprite(SpImage const& image)
|
||||
Sprite::Sprite(ImagePtr const& image)
|
||||
: image_(nullptr)
|
||||
{
|
||||
Load(image);
|
||||
|
|
@ -51,7 +51,7 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
bool Sprite::Load(SpImage const& image)
|
||||
bool Sprite::Load(ImagePtr const& image)
|
||||
{
|
||||
if (image)
|
||||
{
|
||||
|
|
@ -90,7 +90,7 @@ namespace easy2d
|
|||
);
|
||||
}
|
||||
|
||||
SpImage const& Sprite::GetImage() const
|
||||
ImagePtr const& Sprite::GetImage() const
|
||||
{
|
||||
return image_;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ namespace easy2d
|
|||
Sprite();
|
||||
|
||||
explicit Sprite(
|
||||
SpImage const& image
|
||||
ImagePtr const& image
|
||||
);
|
||||
|
||||
explicit Sprite(
|
||||
|
|
@ -53,7 +53,7 @@ namespace easy2d
|
|||
|
||||
// 加载图片
|
||||
bool Load(
|
||||
SpImage const& image
|
||||
ImagePtr const& image
|
||||
);
|
||||
|
||||
// 将图片裁剪为矩形
|
||||
|
|
@ -62,12 +62,12 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取 Image 对象
|
||||
SpImage const& GetImage() const;
|
||||
ImagePtr const& GetImage() const;
|
||||
|
||||
// 渲染精灵
|
||||
virtual void OnRender() override;
|
||||
|
||||
protected:
|
||||
SpImage image_;
|
||||
ImagePtr image_;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,10 +31,10 @@ namespace easy2d
|
|||
// 定时任务
|
||||
class Task
|
||||
: public Object
|
||||
, protected intrusive::ListItem<SpTask>
|
||||
, protected intrusive::ListItem<TaskPtr>
|
||||
{
|
||||
friend class TaskManager;
|
||||
friend class intrusive::List<SpTask>;
|
||||
friend class intrusive::List<TaskPtr>;
|
||||
|
||||
using Callback = std::function<void()>;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ namespace easy2d
|
|||
if (tasks_.IsEmpty())
|
||||
return;
|
||||
|
||||
SpTask next;
|
||||
TaskPtr next;
|
||||
for (auto task = tasks_.First(); task; task = next)
|
||||
{
|
||||
next = task->NextItem();
|
||||
|
|
@ -41,7 +41,7 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
void TaskManager::AddTask(SpTask const& task)
|
||||
void TaskManager::AddTask(TaskPtr const& task)
|
||||
{
|
||||
E2D_ASSERT(task && "AddTask failed, NULL pointer exception");
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ namespace easy2d
|
|||
if (tasks_.IsEmpty())
|
||||
return;
|
||||
|
||||
SpTask next;
|
||||
TaskPtr next;
|
||||
for (auto task = tasks_.First(); task; task = next)
|
||||
{
|
||||
next = task->NextItem();
|
||||
|
|
|
|||
|
|
@ -25,12 +25,12 @@ namespace easy2d
|
|||
{
|
||||
class TaskManager
|
||||
{
|
||||
using Tasks = intrusive::List<SpTask>;
|
||||
using Tasks = intrusive::List<TaskPtr>;
|
||||
|
||||
public:
|
||||
// 添加任务
|
||||
void AddTask(
|
||||
SpTask const& task
|
||||
TaskPtr const& task
|
||||
);
|
||||
|
||||
// 启动任务
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
void Text::SetLineSpacing(float line_spacing)
|
||||
void Text::SetLineacingPtr(float line_spacing)
|
||||
{
|
||||
if (style_.line_spacing != line_spacing)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 设置行间距(默认为 0)
|
||||
void SetLineSpacing(
|
||||
void SetLineacingPtr(
|
||||
float line_spacing
|
||||
);
|
||||
|
||||
|
|
@ -208,7 +208,7 @@ namespace easy2d
|
|||
String text_;
|
||||
Font font_;
|
||||
TextStyle style_;
|
||||
CpTextFormat text_format_;
|
||||
CpTextLayout text_layout_;
|
||||
D2DTextFormatPtr text_format_;
|
||||
D2DTextLayoutPtr text_layout_;
|
||||
};
|
||||
}
|
||||
|
|
@ -123,4 +123,4 @@ namespace easy2d
|
|||
};
|
||||
}
|
||||
|
||||
E2D_DECLARE_D2D_SMART_PTR(easy2d::ITextRenderer, CpTextRenderer);
|
||||
E2D_DECLARE_D2D_SMART_PTR(easy2d::ITextRenderer, D2DTextRendererPtr);
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ namespace easy2d
|
|||
return done_;
|
||||
}
|
||||
|
||||
void Transition::Init(SpScene const& prev, SpScene const& next)
|
||||
void Transition::Init(ScenePtr const& prev, ScenePtr const& next)
|
||||
{
|
||||
process_ = 0;
|
||||
delta_ = Duration{};
|
||||
|
|
@ -147,7 +147,7 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
void BoxTransition::Init(SpScene const& prev, SpScene const& next)
|
||||
void BoxTransition::Init(ScenePtr const& prev, ScenePtr const& next)
|
||||
{
|
||||
Transition::Init(prev, next);
|
||||
|
||||
|
|
@ -189,7 +189,7 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
void EmergeTransition::Init(SpScene const& prev, SpScene const& next)
|
||||
void EmergeTransition::Init(ScenePtr const& prev, ScenePtr const& next)
|
||||
{
|
||||
Transition::Init(prev, next);
|
||||
|
||||
|
|
@ -214,7 +214,7 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
void FadeTransition::Init(SpScene const& prev, SpScene const& next)
|
||||
void FadeTransition::Init(ScenePtr const& prev, ScenePtr const& next)
|
||||
{
|
||||
Transition::Init(prev, next);
|
||||
|
||||
|
|
@ -248,7 +248,7 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
void MoveTransition::Init(SpScene const& prev, SpScene const& next)
|
||||
void MoveTransition::Init(ScenePtr const& prev, ScenePtr const& next)
|
||||
{
|
||||
Transition::Init(prev, next);
|
||||
|
||||
|
|
@ -327,7 +327,7 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
void RotationTransition::Init(SpScene const& prev, SpScene const& next)
|
||||
void RotationTransition::Init(ScenePtr const& prev, ScenePtr const& next)
|
||||
{
|
||||
Transition::Init(prev, next);
|
||||
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ namespace easy2d
|
|||
|
||||
protected:
|
||||
virtual void Init(
|
||||
SpScene const& prev,
|
||||
SpScene const& next
|
||||
ScenePtr const& prev,
|
||||
ScenePtr const& next
|
||||
);
|
||||
|
||||
virtual void Update(Duration const& dt);
|
||||
|
|
@ -61,10 +61,10 @@ namespace easy2d
|
|||
Duration duration_;
|
||||
Duration delta_;
|
||||
Size window_size_;
|
||||
SpScene out_scene_;
|
||||
SpScene in_scene_;
|
||||
CpLayer out_layer_;
|
||||
CpLayer in_layer_;
|
||||
ScenePtr out_scene_;
|
||||
ScenePtr in_scene_;
|
||||
D2DLayerPtr out_layer_;
|
||||
D2DLayerPtr in_layer_;
|
||||
LayerProperties out_layer_prop_;
|
||||
LayerProperties in_layer_prop_;
|
||||
};
|
||||
|
|
@ -84,8 +84,8 @@ namespace easy2d
|
|||
virtual void Update(Duration const& dt) override;
|
||||
|
||||
virtual void Init(
|
||||
SpScene const& prev,
|
||||
SpScene const& next
|
||||
ScenePtr const& prev,
|
||||
ScenePtr const& next
|
||||
) override;
|
||||
};
|
||||
|
||||
|
|
@ -103,8 +103,8 @@ namespace easy2d
|
|||
virtual void Update(Duration const& dt) override;
|
||||
|
||||
virtual void Init(
|
||||
SpScene const& prev,
|
||||
SpScene const& next
|
||||
ScenePtr const& prev,
|
||||
ScenePtr const& next
|
||||
) override;
|
||||
};
|
||||
|
||||
|
|
@ -122,8 +122,8 @@ namespace easy2d
|
|||
virtual void Update(Duration const& dt) override;
|
||||
|
||||
virtual void Init(
|
||||
SpScene const& prev,
|
||||
SpScene const& next
|
||||
ScenePtr const& prev,
|
||||
ScenePtr const& next
|
||||
) override;
|
||||
};
|
||||
|
||||
|
|
@ -142,8 +142,8 @@ namespace easy2d
|
|||
virtual void Update(Duration const& dt) override;
|
||||
|
||||
virtual void Init(
|
||||
SpScene const& prev,
|
||||
SpScene const& next
|
||||
ScenePtr const& prev,
|
||||
ScenePtr const& next
|
||||
) override;
|
||||
|
||||
virtual void Reset() override;
|
||||
|
|
@ -169,8 +169,8 @@ namespace easy2d
|
|||
virtual void Update(Duration const& dt) override;
|
||||
|
||||
virtual void Init(
|
||||
SpScene const& prev,
|
||||
SpScene const& next
|
||||
ScenePtr const& prev,
|
||||
ScenePtr const& next
|
||||
) override;
|
||||
|
||||
virtual void Reset() override;
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ namespace easy2d
|
|||
|
||||
AudioDevice::~AudioDevice()
|
||||
{
|
||||
E2D_LOG("Destroying audio device");
|
||||
E2D_LOG(L"Destroying audio device");
|
||||
|
||||
ClearVoiceCache();
|
||||
|
||||
|
|
@ -179,18 +179,18 @@ namespace easy2d
|
|||
|
||||
SafeRelease(x_audio2_);
|
||||
|
||||
modules::MediaFoundation().MFShutdown();
|
||||
modules::MediaFoundation::Get().MFShutdown();
|
||||
}
|
||||
|
||||
HRESULT AudioDevice::Init(bool debug)
|
||||
{
|
||||
E2D_LOG("Initing audio device");
|
||||
E2D_LOG(L"Initing audio device");
|
||||
|
||||
HRESULT hr = modules::MediaFoundation().MFStartup(MF_VERSION, MFSTARTUP_FULL);
|
||||
HRESULT hr = modules::MediaFoundation::Get().MFStartup(MF_VERSION, MFSTARTUP_FULL);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = modules::XAudio2().XAudio2Create(&x_audio2_, 0, XAUDIO2_DEFAULT_PROCESSOR);
|
||||
hr = modules::XAudio2::Get().XAudio2Create(&x_audio2_, 0, XAUDIO2_DEFAULT_PROCESSOR);
|
||||
}
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
|
|
|
|||
|
|
@ -19,42 +19,42 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include "intrusive/SmartPointer.hpp"
|
||||
#include "intrusive/SmartPtr.hpp"
|
||||
#include <d2d1.h>
|
||||
#include <dwrite.h>
|
||||
|
||||
#ifndef E2D_DECLARE_D2D_SMART_PTR
|
||||
#define E2D_DECLARE_D2D_SMART_PTR(class_name, sp_name)\
|
||||
using sp_name = ::easy2d::intrusive::SmartPointer< class_name >
|
||||
using sp_name = ::easy2d::intrusive::SmartPtr< class_name >
|
||||
#endif
|
||||
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
// "Cp" is a shorthand for "COM Pointer"
|
||||
// "D2DPtr" is a shorthand for "COM Pointer"
|
||||
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1Factory, CpFactory);
|
||||
E2D_DECLARE_D2D_SMART_PTR(IWICImagingFactory, CpImagingFactory);
|
||||
E2D_DECLARE_D2D_SMART_PTR(IDWriteFactory, CpWriteFactory);
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1SolidColorBrush, CpSolidColorBrush);
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1RenderTarget, CpRenderTarget);
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1HwndRenderTarget, CpHwndRenderTarget);
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1BitmapRenderTarget, CpBitmapRenderTarget);
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1StrokeStyle, CpStrokeStyle);
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1Factory, D2DFactoryPtr);
|
||||
E2D_DECLARE_D2D_SMART_PTR(IWICImagingFactory, D2DImagingFactoryPtr);
|
||||
E2D_DECLARE_D2D_SMART_PTR(IDWriteFactory, D2DWriteFactoryPtr);
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1SolidColorBrush, D2DSolidColorBrushPtr);
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1RenderTarget, D2DRenderTargetPtr);
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1HwndRenderTarget, D2DHwndRenderTargetPtr);
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1BitmapRenderTarget, D2DBitmapRenderTargetPtr);
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1StrokeStyle, D2DStrokeStylePtr);
|
||||
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1Geometry, CpGeometry);
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1RectangleGeometry, CpRectangleGeometry);
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1RoundedRectangleGeometry, CpRoundedRectangleGeometry);
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1EllipseGeometry, CpEllipseGeometry);
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1GeometryGroup, CpGeometryGroup);
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1PathGeometry, CpPathGeometry);
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1TransformedGeometry, CpTransformedGeometry);
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1GeometrySink, CpGeometrySink);
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1Geometry, D2DGeometryPtr);
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1RectangleGeometry, D2DRectangleGeometryPtr);
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1RoundedRectangleGeometry, D2DRoundedRectangleGeometryPtr);
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1EllipseGeometry, D2DEllipseGeometryPtr);
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1GeometryGroup, D2DGeometryGroupPtr);
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1PathGeometry, D2DPathGeometryPtr);
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1TransformedGeometry, D2DTransformedGeometryPtr);
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1GeometrySink, D2DGeometrySinkPtr);
|
||||
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1Layer, CpLayer);
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1Bitmap, CpBitmap);
|
||||
E2D_DECLARE_D2D_SMART_PTR(IDWriteTextFormat, CpTextFormat);
|
||||
E2D_DECLARE_D2D_SMART_PTR(IDWriteTextLayout, CpTextLayout);
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1Layer, D2DLayerPtr);
|
||||
E2D_DECLARE_D2D_SMART_PTR(ID2D1Bitmap, D2DBitmapPtr);
|
||||
E2D_DECLARE_D2D_SMART_PTR(IDWriteTextFormat, D2DTextFormatPtr);
|
||||
E2D_DECLARE_D2D_SMART_PTR(IDWriteTextLayout, D2DTextLayoutPtr);
|
||||
|
||||
inline void IntrusivePtrAddRef(IUnknown* ptr)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#pragma once
|
||||
#include "RefCounter.hpp"
|
||||
#include "intrusive/SmartPointer.hpp"
|
||||
#include "intrusive/SmartPtr.hpp"
|
||||
#include "../math/vector.hpp"
|
||||
#include "../math/Rect.hpp"
|
||||
#include "../math/Matrix.hpp"
|
||||
|
|
@ -34,13 +34,13 @@
|
|||
#ifndef E2D_DECLARE_SMART_PTR
|
||||
#define E2D_DECLARE_SMART_PTR(class_name)\
|
||||
class class_name;\
|
||||
using Sp##class_name = ::easy2d::intrusive::SmartPointer< class_name >
|
||||
using class_name##Ptr = ::easy2d::intrusive::SmartPtr< class_name >
|
||||
|
||||
#define E2D_DECLARE_NS_SMART_PTR(ns_name, class_name)\
|
||||
namespace ns_name\
|
||||
{\
|
||||
class class_name; \
|
||||
using Sp##class_name = ::easy2d::intrusive::SmartPointer< class_name >;\
|
||||
using class_name##Ptr = ::easy2d::intrusive::SmartPtr< class_name >;\
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -70,8 +70,9 @@ namespace easy2d
|
|||
|
||||
namespace easy2d
|
||||
{
|
||||
// "Sp" is a shorthand for "Smart Pointer"
|
||||
// "Ptr" is a shorthand for "Smart Pointer"
|
||||
|
||||
E2D_DECLARE_SMART_PTR(Object);
|
||||
E2D_DECLARE_SMART_PTR(Image);
|
||||
E2D_DECLARE_SMART_PTR(Music);
|
||||
E2D_DECLARE_SMART_PTR(Task);
|
||||
|
|
@ -140,9 +141,9 @@ namespace easy2d
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
inline intrusive::SmartPointer<T> operator- (T* ptr) const
|
||||
inline intrusive::SmartPtr<T> operator- (T* ptr) const
|
||||
{
|
||||
return intrusive::SmartPointer<T>(ptr);
|
||||
return intrusive::SmartPtr<T>(ptr);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,47 +27,49 @@ namespace easy2d
|
|||
namespace intrusive
|
||||
{
|
||||
template <typename T>
|
||||
class SmartPointer
|
||||
class SmartPtr
|
||||
{
|
||||
T* ptr_{ nullptr };
|
||||
|
||||
public:
|
||||
using Type = T;
|
||||
|
||||
SmartPointer() E2D_NOEXCEPT {}
|
||||
SmartPtr() E2D_NOEXCEPT {}
|
||||
|
||||
SmartPointer(nullptr_t) E2D_NOEXCEPT {}
|
||||
SmartPtr(nullptr_t) E2D_NOEXCEPT {}
|
||||
|
||||
SmartPointer(Type* p) E2D_NOEXCEPT : ptr_(p)
|
||||
SmartPtr(Type* p) E2D_NOEXCEPT : ptr_(p)
|
||||
{
|
||||
IntrusivePtrAddRef(ptr_);
|
||||
}
|
||||
|
||||
SmartPointer(const SmartPointer& other) E2D_NOEXCEPT : ptr_(other.ptr_)
|
||||
SmartPtr(const SmartPtr& other) E2D_NOEXCEPT
|
||||
: ptr_(other.ptr_)
|
||||
{
|
||||
IntrusivePtrAddRef(ptr_);
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
SmartPointer(const SmartPointer<U>& other) E2D_NOEXCEPT : ptr_(other.Get())
|
||||
SmartPtr(const SmartPtr<U>& other) E2D_NOEXCEPT
|
||||
: ptr_(other.Get())
|
||||
{
|
||||
IntrusivePtrAddRef(ptr_);
|
||||
}
|
||||
|
||||
SmartPointer(SmartPointer&& other) E2D_NOEXCEPT
|
||||
SmartPtr(SmartPtr&& other) E2D_NOEXCEPT
|
||||
{
|
||||
ptr_ = other.ptr_;
|
||||
other.ptr_ = nullptr;
|
||||
}
|
||||
|
||||
~SmartPointer() E2D_NOEXCEPT
|
||||
~SmartPtr() E2D_NOEXCEPT
|
||||
{
|
||||
IntrusivePtrRelease(ptr_);
|
||||
}
|
||||
|
||||
inline Type* Get() const E2D_NOEXCEPT { return ptr_; }
|
||||
|
||||
inline void Swap(SmartPointer& other) E2D_NOEXCEPT
|
||||
inline void Swap(SmartPtr& other) E2D_NOEXCEPT
|
||||
{
|
||||
std::swap(ptr_, other.ptr_);
|
||||
}
|
||||
|
|
@ -94,14 +96,14 @@ namespace easy2d
|
|||
|
||||
inline bool operator !() const E2D_NOEXCEPT { return ptr_ == 0; }
|
||||
|
||||
inline SmartPointer& operator =(const SmartPointer& other) E2D_NOEXCEPT
|
||||
inline SmartPtr& operator =(const SmartPtr& other) E2D_NOEXCEPT
|
||||
{
|
||||
if (other.ptr_ != ptr_)
|
||||
SmartPointer(other).Swap(*this);
|
||||
SmartPtr(other).Swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline SmartPointer& operator =(SmartPointer&& other) E2D_NOEXCEPT
|
||||
inline SmartPtr& operator =(SmartPtr&& other) E2D_NOEXCEPT
|
||||
{
|
||||
IntrusivePtrRelease(ptr_);
|
||||
ptr_ = other.ptr_;
|
||||
|
|
@ -109,83 +111,83 @@ namespace easy2d
|
|||
return *this;
|
||||
}
|
||||
|
||||
inline SmartPointer& operator =(Type* p) E2D_NOEXCEPT
|
||||
inline SmartPtr& operator =(Type* p) E2D_NOEXCEPT
|
||||
{
|
||||
if (p != ptr_)
|
||||
SmartPointer(p).Swap(*this);
|
||||
SmartPtr(p).Swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline SmartPointer& operator =(nullptr_t) E2D_NOEXCEPT
|
||||
inline SmartPtr& operator =(nullptr_t) E2D_NOEXCEPT
|
||||
{
|
||||
if (nullptr != ptr_)
|
||||
SmartPointer{}.Swap(*this);
|
||||
SmartPtr{}.Swap(*this);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, class U>
|
||||
inline bool operator==(SmartPointer<T> const& lhs, SmartPointer<U> const& rhs) E2D_NOEXCEPT
|
||||
inline bool operator==(SmartPtr<T> const& lhs, SmartPtr<U> const& rhs) E2D_NOEXCEPT
|
||||
{
|
||||
return lhs.Get() == rhs.Get();
|
||||
}
|
||||
|
||||
template<class T, class U>
|
||||
inline bool operator!=(SmartPointer<T> const& lhs, SmartPointer<U> const& rhs) E2D_NOEXCEPT
|
||||
inline bool operator!=(SmartPtr<T> const& lhs, SmartPtr<U> const& rhs) E2D_NOEXCEPT
|
||||
{
|
||||
return lhs.Get() != rhs.Get();
|
||||
}
|
||||
|
||||
template<class T, class U>
|
||||
inline bool operator<(SmartPointer<T> const& lhs, SmartPointer<U> const& rhs) E2D_NOEXCEPT
|
||||
inline bool operator<(SmartPtr<T> const& lhs, SmartPtr<U> const& rhs) E2D_NOEXCEPT
|
||||
{
|
||||
return lhs.Get() < rhs.Get();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool operator==(SmartPointer<T> const& lhs, T* rhs) E2D_NOEXCEPT
|
||||
inline bool operator==(SmartPtr<T> const& lhs, T* rhs) E2D_NOEXCEPT
|
||||
{
|
||||
return lhs.Get() == rhs;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool operator!=(SmartPointer<T> const& lhs, T* rhs) E2D_NOEXCEPT
|
||||
inline bool operator!=(SmartPtr<T> const& lhs, T* rhs) E2D_NOEXCEPT
|
||||
{
|
||||
return lhs.Get() != rhs;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool operator==(T* lhs, SmartPointer<T> const& rhs) E2D_NOEXCEPT
|
||||
inline bool operator==(T* lhs, SmartPtr<T> const& rhs) E2D_NOEXCEPT
|
||||
{
|
||||
return lhs == rhs.Get();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool operator!=(T* lhs, SmartPointer<T> const& rhs) E2D_NOEXCEPT
|
||||
inline bool operator!=(T* lhs, SmartPtr<T> const& rhs) E2D_NOEXCEPT
|
||||
{
|
||||
return lhs != rhs.Get();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool operator==(SmartPointer<T> const& lhs, nullptr_t) E2D_NOEXCEPT
|
||||
inline bool operator==(SmartPtr<T> const& lhs, nullptr_t) E2D_NOEXCEPT
|
||||
{
|
||||
return !static_cast<bool>(lhs);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool operator!=(SmartPointer<T> const& lhs, nullptr_t) E2D_NOEXCEPT
|
||||
inline bool operator!=(SmartPtr<T> const& lhs, nullptr_t) E2D_NOEXCEPT
|
||||
{
|
||||
return static_cast<bool>(lhs);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool operator==(nullptr_t, SmartPointer<T> const& rhs) E2D_NOEXCEPT
|
||||
inline bool operator==(nullptr_t, SmartPtr<T> const& rhs) E2D_NOEXCEPT
|
||||
{
|
||||
return !static_cast<bool>(rhs);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool operator!=(nullptr_t, SmartPointer<T> const& rhs) E2D_NOEXCEPT
|
||||
inline bool operator!=(nullptr_t, SmartPtr<T> const& rhs) E2D_NOEXCEPT
|
||||
{
|
||||
return static_cast<bool>(rhs);
|
||||
}
|
||||
|
|
@ -194,7 +196,7 @@ namespace easy2d
|
|||
// template class cannot specialize std::swap,
|
||||
// so implement a swap function in easy2d namespace
|
||||
template<class T>
|
||||
inline void swap(intrusive::SmartPointer<T>& lhs, intrusive::SmartPointer<T>& rhs) E2D_NOEXCEPT
|
||||
inline void swap(intrusive::SmartPtr<T>& lhs, intrusive::SmartPtr<T>& rhs) E2D_NOEXCEPT
|
||||
{
|
||||
lhs.Swap(rhs);
|
||||
}
|
||||
|
|
@ -32,7 +32,7 @@ namespace easy2d
|
|||
Right = VK_RIGHT,
|
||||
Down = VK_DOWN,
|
||||
Enter = VK_RETURN,
|
||||
Space = VK_SPACE,
|
||||
acePtr = VK_SPACE,
|
||||
Esc = VK_ESCAPE,
|
||||
Ctrl = VK_CONTROL,
|
||||
Shift = VK_SHIFT,
|
||||
|
|
|
|||
|
|
@ -33,30 +33,30 @@ namespace easy2d
|
|||
{
|
||||
bool enabled = true;
|
||||
|
||||
void Out(std::ostream& stream, const char* output)
|
||||
void Out(std::ostream& stream, const wchar_t* output)
|
||||
{
|
||||
stream << output;
|
||||
::OutputDebugStringA(output);
|
||||
::OutputDebugStringW(output);
|
||||
}
|
||||
|
||||
void OutPrefix(std::stringstream& ss)
|
||||
void OutPrefix(std::wstringstream& ss)
|
||||
{
|
||||
std::time_t unix = ::time(NULL);
|
||||
struct tm tmbuf;
|
||||
localtime_s(&tmbuf, &unix);
|
||||
ss << std::put_time(&tmbuf, "[easy2d] %H:%M:%S ");
|
||||
ss << std::put_time(&tmbuf, L"[easy2d] %H:%M:%S ");
|
||||
}
|
||||
|
||||
void Output(std::ostream& stream, const char* prompt, const char* format, va_list args)
|
||||
void Output(std::ostream& stream, const wchar_t* prompt, const wchar_t* format, va_list args)
|
||||
{
|
||||
if (!enabled)
|
||||
return;
|
||||
|
||||
size_t len = ::_vscprintf(format, args) + 1;
|
||||
char* buffer = new char[len];
|
||||
::_vsnprintf_s(buffer, len, len, format, args);
|
||||
size_t len = ::_vscwprintf(format, args) + 1;
|
||||
wchar_t* buffer = new wchar_t[len];
|
||||
::_vsnwprintf_s(buffer, len, len, format, args);
|
||||
|
||||
std::stringstream ss;
|
||||
std::wstringstream ss;
|
||||
OutPrefix(ss);
|
||||
ss << prompt << buffer;
|
||||
Out(stream, ss.str().c_str());
|
||||
|
|
@ -64,13 +64,13 @@ namespace easy2d
|
|||
delete[] buffer;
|
||||
}
|
||||
|
||||
void OutputLine(std::ostream& stream, const char* prompt, const char* format, va_list args)
|
||||
void OutputLine(std::ostream& stream, const wchar_t* prompt, const wchar_t* format, va_list args)
|
||||
{
|
||||
if (!enabled)
|
||||
return;
|
||||
|
||||
Output(stream, prompt, format, args);
|
||||
Out(stream, "\r\n");
|
||||
Out(stream, L"\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -84,74 +84,74 @@ namespace easy2d
|
|||
enabled = false;
|
||||
}
|
||||
|
||||
void Print(const char* format, ...)
|
||||
void Print(const wchar_t* format, ...)
|
||||
{
|
||||
va_list args = nullptr;
|
||||
va_start(args, format);
|
||||
|
||||
Output(std::cout, "", format, args);
|
||||
Output(std::cout, L"", format, args);
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void Println(const char* format, ...)
|
||||
void Println(const wchar_t* format, ...)
|
||||
{
|
||||
va_list args = nullptr;
|
||||
va_start(args, format);
|
||||
|
||||
OutputLine(std::cout, "", format, args);
|
||||
OutputLine(std::cout, L"", format, args);
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void Warning(const char* format, ...)
|
||||
void Warning(const wchar_t* format, ...)
|
||||
{
|
||||
va_list args = nullptr;
|
||||
va_start(args, format);
|
||||
|
||||
Output(std::cerr, "Warning: ", format, args);
|
||||
Output(std::cerr, L"Warning: ", format, args);
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void Warningln(const char* format, ...)
|
||||
void Warningln(const wchar_t* format, ...)
|
||||
{
|
||||
va_list args = nullptr;
|
||||
va_start(args, format);
|
||||
|
||||
OutputLine(std::cerr, "Warning: ", format, args);
|
||||
OutputLine(std::cerr, L"Warning: ", format, args);
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void Error(const char* format, ...)
|
||||
void Error(const wchar_t* format, ...)
|
||||
{
|
||||
va_list args = nullptr;
|
||||
va_start(args, format);
|
||||
|
||||
Output(std::cerr, "Error: ", format, args);
|
||||
Output(std::cerr, L"Error: ", format, args);
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void Errorln(const char* format, ...)
|
||||
void Errorln(const wchar_t* format, ...)
|
||||
{
|
||||
va_list args = nullptr;
|
||||
va_start(args, format);
|
||||
|
||||
OutputLine(std::cerr, "Error: ", format, args);
|
||||
OutputLine(std::cerr, L"Error: ", format, args);
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void Errorln(HRESULT hr)
|
||||
{
|
||||
Errorln("failure with HRESULT of %08X", hr);
|
||||
Errorln(L"failure with HRESULT of %08X", hr);
|
||||
}
|
||||
|
||||
void Errorln(HRESULT hr, const char* output)
|
||||
void Errorln(HRESULT hr, const wchar_t* output)
|
||||
{
|
||||
Errorln("failure with HRESULT of %08X: %s", hr, output);
|
||||
Errorln(L"failure with HRESULT of %08X: %s", hr, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,21 +37,21 @@ namespace easy2d
|
|||
|
||||
void Disable();
|
||||
|
||||
void Print(const char* format, ...);
|
||||
void Print(const wchar_t* format, ...);
|
||||
|
||||
void Println(const char* format, ...);
|
||||
void Println(const wchar_t* format, ...);
|
||||
|
||||
void Warning(const char* format, ...);
|
||||
void Warning(const wchar_t* format, ...);
|
||||
|
||||
void Warningln(const char* format, ...);
|
||||
void Warningln(const wchar_t* format, ...);
|
||||
|
||||
void Error(const char* format, ...);
|
||||
void Error(const wchar_t* format, ...);
|
||||
|
||||
void Errorln(const char* format, ...);
|
||||
void Errorln(const wchar_t* format, ...);
|
||||
|
||||
void Errorln(HRESULT hr);
|
||||
|
||||
void Errorln(HRESULT hr, const char* output);
|
||||
void Errorln(HRESULT hr, const wchar_t* output);
|
||||
}
|
||||
|
||||
inline void ThrowIfFailed(HRESULT hr)
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ namespace easy2d
|
|||
}
|
||||
else
|
||||
{
|
||||
E2D_LOG("load shlapi.dll failed");
|
||||
E2D_LOG(L"load shlapi.dll failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ namespace easy2d
|
|||
}
|
||||
else
|
||||
{
|
||||
E2D_LOG("load d2d.dll failed");
|
||||
E2D_LOG(L"load d2d.dll failed");
|
||||
}
|
||||
|
||||
dwrite = LoadLibraryW(L"dwrite.dll");
|
||||
|
|
@ -63,7 +63,7 @@ namespace easy2d
|
|||
}
|
||||
else
|
||||
{
|
||||
E2D_LOG("load dwrite.dll failed");
|
||||
E2D_LOG(L"load dwrite.dll failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -89,7 +89,7 @@ namespace easy2d
|
|||
|
||||
if (!xaudio2)
|
||||
{
|
||||
E2D_LOG("load xaudio2.dll failed");
|
||||
E2D_LOG(L"load xaudio2.dll failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -115,7 +115,7 @@ namespace easy2d
|
|||
}
|
||||
else
|
||||
{
|
||||
E2D_LOG("load Mfplat.dll failed");
|
||||
E2D_LOG(L"load Mfplat.dll failed");
|
||||
}
|
||||
|
||||
mfreadwrite = LoadLibraryW(L"Mfreadwrite.dll");
|
||||
|
|
@ -129,7 +129,7 @@ namespace easy2d
|
|||
}
|
||||
else
|
||||
{
|
||||
E2D_LOG("load Mfreadwrite.dll failed");
|
||||
E2D_LOG(L"load Mfreadwrite.dll failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ namespace easy2d
|
|||
{
|
||||
class Shlwapi
|
||||
{
|
||||
Shlwapi();
|
||||
|
||||
HMODULE shlwapi;
|
||||
|
||||
// Shlwapi functions
|
||||
|
|
@ -40,7 +42,11 @@ namespace easy2d
|
|||
typedef IStream*(WINAPI *PFN_SHCreateMemStream)(const BYTE*, UINT);
|
||||
|
||||
public:
|
||||
Shlwapi();
|
||||
static Shlwapi& Get()
|
||||
{
|
||||
static Shlwapi instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
PFN_PathFileExistsW PathFileExistsW;
|
||||
PFN_SHCreateMemStream SHCreateMemStream;
|
||||
|
|
@ -49,6 +55,8 @@ namespace easy2d
|
|||
|
||||
class DirectX
|
||||
{
|
||||
DirectX();
|
||||
|
||||
HMODULE d2d;
|
||||
HMODULE dwrite;
|
||||
|
||||
|
|
@ -57,7 +65,11 @@ namespace easy2d
|
|||
typedef HRESULT(WINAPI *PFN_DWriteCreateFactory)(DWRITE_FACTORY_TYPE, const IID&, IUnknown **);
|
||||
|
||||
public:
|
||||
DirectX();
|
||||
static DirectX& Get()
|
||||
{
|
||||
static DirectX instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
PFN_D2D1CreateFactory D2D1CreateFactory;
|
||||
PFN_DWriteCreateFactory DWriteCreateFactory;
|
||||
|
|
@ -66,13 +78,19 @@ namespace easy2d
|
|||
|
||||
class XAudio2
|
||||
{
|
||||
XAudio2();
|
||||
|
||||
HMODULE xaudio2;
|
||||
|
||||
// XAudio2 functions
|
||||
typedef HRESULT(WINAPI *PFN_XAudio2Create)(IXAudio2**, UINT32, XAUDIO2_PROCESSOR);
|
||||
|
||||
public:
|
||||
XAudio2();
|
||||
static XAudio2& Get()
|
||||
{
|
||||
static XAudio2 instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
PFN_XAudio2Create XAudio2Create;
|
||||
};
|
||||
|
|
@ -80,6 +98,8 @@ namespace easy2d
|
|||
|
||||
class MediaFoundation
|
||||
{
|
||||
MediaFoundation();
|
||||
|
||||
HMODULE mfplat;
|
||||
HMODULE mfreadwrite;
|
||||
|
||||
|
|
@ -93,7 +113,11 @@ namespace easy2d
|
|||
typedef HRESULT(WINAPI *PFN_MFCreateMFByteStreamOnStream)(IStream*, IMFByteStream**);
|
||||
|
||||
public:
|
||||
MediaFoundation();
|
||||
static MediaFoundation& Get()
|
||||
{
|
||||
static MediaFoundation instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
PFN_MFStartup MFStartup;
|
||||
PFN_MFShutdown MFShutdown;
|
||||
|
|
|
|||
|
|
@ -41,14 +41,14 @@ namespace easy2d
|
|||
|
||||
GraphicsDevice::~GraphicsDevice()
|
||||
{
|
||||
E2D_LOG("Destroying graphics device");
|
||||
E2D_LOG(L"Destroying graphics device");
|
||||
|
||||
ClearImageCache();
|
||||
}
|
||||
|
||||
HRESULT GraphicsDevice::Init(HWND hwnd, bool vsync, bool debug)
|
||||
{
|
||||
E2D_LOG("Initing graphics device");
|
||||
E2D_LOG(L"Initing graphics device");
|
||||
|
||||
vsync_enabled_ = vsync;
|
||||
debug_ = debug;
|
||||
|
|
@ -108,17 +108,17 @@ namespace easy2d
|
|||
bitmap_cache_.clear();
|
||||
}
|
||||
|
||||
CpHwndRenderTarget const & GraphicsDevice::GetRenderTarget() const
|
||||
D2DHwndRenderTargetPtr const & GraphicsDevice::GetRenderTarget() const
|
||||
{
|
||||
return render_target_;
|
||||
}
|
||||
|
||||
CpSolidColorBrush const & GraphicsDevice::GetSolidBrush() const
|
||||
D2DSolidColorBrushPtr const & GraphicsDevice::GetSolidBrush() const
|
||||
{
|
||||
return solid_brush_;
|
||||
}
|
||||
|
||||
HRESULT GraphicsDevice::CreateLayer(CpLayer& layer)
|
||||
HRESULT GraphicsDevice::CreateLayer(D2DLayerPtr& layer)
|
||||
{
|
||||
if (!render_target_)
|
||||
return E_UNEXPECTED;
|
||||
|
|
@ -127,7 +127,7 @@ namespace easy2d
|
|||
return render_target_->CreateLayer(&layer);
|
||||
}
|
||||
|
||||
HRESULT GraphicsDevice::CreateSolidColorBrush(CpSolidColorBrush & brush) const
|
||||
HRESULT GraphicsDevice::CreateSolidColorBrush(D2DSolidColorBrushPtr & brush) const
|
||||
{
|
||||
if (!render_target_)
|
||||
return E_UNEXPECTED;
|
||||
|
|
@ -140,7 +140,7 @@ namespace easy2d
|
|||
}
|
||||
|
||||
HRESULT GraphicsDevice::DrawGeometry(
|
||||
CpGeometry const& geometry,
|
||||
D2DGeometryPtr const& geometry,
|
||||
Color const& stroke_color,
|
||||
float stroke_width,
|
||||
StrokeStyle stroke
|
||||
|
|
@ -167,7 +167,7 @@ namespace easy2d
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT GraphicsDevice::FillGeometry(CpGeometry const & geometry, const Color & fill_color)
|
||||
HRESULT GraphicsDevice::FillGeometry(D2DGeometryPtr const & geometry, const Color & fill_color)
|
||||
{
|
||||
if (!solid_brush_ ||
|
||||
!render_target_)
|
||||
|
|
@ -187,7 +187,7 @@ namespace easy2d
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT GraphicsDevice::DrawImage(SpImage const & image)
|
||||
HRESULT GraphicsDevice::DrawImage(ImagePtr const & image)
|
||||
{
|
||||
if (!render_target_)
|
||||
return E_UNEXPECTED;
|
||||
|
|
@ -212,7 +212,7 @@ namespace easy2d
|
|||
}
|
||||
|
||||
HRESULT GraphicsDevice::DrawBitmap(
|
||||
CpBitmap const& bitmap
|
||||
D2DBitmapPtr const& bitmap
|
||||
)
|
||||
{
|
||||
if (!render_target_)
|
||||
|
|
@ -236,7 +236,7 @@ namespace easy2d
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT GraphicsDevice::DrawTextLayout(CpTextLayout const& text_layout)
|
||||
HRESULT GraphicsDevice::DrawTextLayout(D2DTextLayoutPtr const& text_layout)
|
||||
{
|
||||
if (!text_renderer_)
|
||||
return E_UNEXPECTED;
|
||||
|
|
@ -277,7 +277,7 @@ namespace easy2d
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT GraphicsDevice::PushLayer(CpLayer const& layer, LayerProperties const& properties)
|
||||
HRESULT GraphicsDevice::PushLayer(D2DLayerPtr const& layer, LayerProperties const& properties)
|
||||
{
|
||||
if (!render_target_ ||
|
||||
!solid_brush_)
|
||||
|
|
@ -324,7 +324,7 @@ namespace easy2d
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT GraphicsDevice::CreateBitmapFromFile(CpBitmap& bitmap, String const& file_path)
|
||||
HRESULT GraphicsDevice::CreateBitmapFromFile(D2DBitmapPtr& bitmap, String const& file_path)
|
||||
{
|
||||
if (render_target_ == nullptr)
|
||||
{
|
||||
|
|
@ -338,7 +338,7 @@ namespace easy2d
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
CpBitmap bitmap_tmp;
|
||||
D2DBitmapPtr bitmap_tmp;
|
||||
HRESULT hr = Factory::Instance()->CreateBitmapFromFile(
|
||||
bitmap,
|
||||
render_target_,
|
||||
|
|
@ -353,7 +353,7 @@ namespace easy2d
|
|||
return hr;
|
||||
}
|
||||
|
||||
HRESULT GraphicsDevice::CreateBitmapFromResource(CpBitmap& bitmap, Resource const& res)
|
||||
HRESULT GraphicsDevice::CreateBitmapFromResource(D2DBitmapPtr& bitmap, Resource const& res)
|
||||
{
|
||||
if (render_target_ == nullptr)
|
||||
{
|
||||
|
|
@ -381,7 +381,7 @@ namespace easy2d
|
|||
return hr;
|
||||
}
|
||||
|
||||
HRESULT GraphicsDevice::CreateBitmapRenderTarget(CpBitmapRenderTarget & brt)
|
||||
HRESULT GraphicsDevice::CreateBitmapRenderTarget(D2DBitmapRenderTargetPtr & brt)
|
||||
{
|
||||
if (!render_target_)
|
||||
return E_UNEXPECTED;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ namespace easy2d
|
|||
int primitives;
|
||||
};
|
||||
|
||||
using BitmapMap = UnorderedMap<size_t, CpBitmap>;
|
||||
using BitmapMap = UnorderedMap<size_t, D2DBitmapPtr>;
|
||||
|
||||
public:
|
||||
HRESULT Init(HWND hwnd, bool vsync, bool debug);
|
||||
|
|
@ -78,25 +78,25 @@ namespace easy2d
|
|||
void DiscardResources();
|
||||
|
||||
HRESULT CreateLayer(
|
||||
CpLayer& layer
|
||||
D2DLayerPtr& layer
|
||||
);
|
||||
|
||||
HRESULT CreateSolidColorBrush(
|
||||
CpSolidColorBrush& brush
|
||||
D2DSolidColorBrushPtr& brush
|
||||
) const;
|
||||
|
||||
HRESULT CreateBitmapFromFile(
|
||||
CpBitmap& bitmap,
|
||||
D2DBitmapPtr& bitmap,
|
||||
String const& file_path
|
||||
);
|
||||
|
||||
HRESULT CreateBitmapFromResource(
|
||||
CpBitmap& bitmap,
|
||||
D2DBitmapPtr& bitmap,
|
||||
Resource const& res
|
||||
);
|
||||
|
||||
HRESULT CreateBitmapRenderTarget(
|
||||
CpBitmapRenderTarget& brt
|
||||
D2DBitmapRenderTargetPtr& brt
|
||||
);
|
||||
|
||||
HRESULT SetTransform(
|
||||
|
|
@ -116,27 +116,27 @@ namespace easy2d
|
|||
);
|
||||
|
||||
HRESULT DrawGeometry(
|
||||
CpGeometry const& geometry,
|
||||
D2DGeometryPtr const& geometry,
|
||||
const Color& stroke_color,
|
||||
float stroke_width,
|
||||
StrokeStyle stroke = StrokeStyle::Miter
|
||||
);
|
||||
|
||||
HRESULT FillGeometry(
|
||||
CpGeometry const& geometry,
|
||||
D2DGeometryPtr const& geometry,
|
||||
const Color& fill_color
|
||||
);
|
||||
|
||||
HRESULT DrawImage(
|
||||
SpImage const& image
|
||||
ImagePtr const& image
|
||||
);
|
||||
|
||||
HRESULT DrawBitmap(
|
||||
CpBitmap const& bitmap
|
||||
D2DBitmapPtr const& bitmap
|
||||
);
|
||||
|
||||
HRESULT DrawTextLayout(
|
||||
CpTextLayout const& text_layout
|
||||
D2DTextLayoutPtr const& text_layout
|
||||
);
|
||||
|
||||
HRESULT PushClip(
|
||||
|
|
@ -147,7 +147,7 @@ namespace easy2d
|
|||
HRESULT PopClip();
|
||||
|
||||
HRESULT PushLayer(
|
||||
CpLayer const& layer,
|
||||
D2DLayerPtr const& layer,
|
||||
LayerProperties const& properties
|
||||
);
|
||||
|
||||
|
|
@ -164,9 +164,9 @@ namespace easy2d
|
|||
|
||||
void ClearImageCache();
|
||||
|
||||
CpHwndRenderTarget const& GetRenderTarget() const;
|
||||
D2DHwndRenderTargetPtr const& GetRenderTarget() const;
|
||||
|
||||
CpSolidColorBrush const& GetSolidBrush() const;
|
||||
D2DSolidColorBrushPtr const& GetSolidBrush() const;
|
||||
|
||||
protected:
|
||||
GraphicsDevice();
|
||||
|
|
@ -182,11 +182,11 @@ namespace easy2d
|
|||
D2D1_COLOR_F clear_color_;
|
||||
TextAntialias text_antialias_;
|
||||
Status status_;
|
||||
CpTextRenderer text_renderer_;
|
||||
CpSolidColorBrush solid_brush_;
|
||||
CpHwndRenderTarget render_target_;
|
||||
CpTextFormat fps_text_format_;
|
||||
CpTextLayout fps_text_layout_;
|
||||
D2DTextRendererPtr text_renderer_;
|
||||
D2DSolidColorBrushPtr solid_brush_;
|
||||
D2DHwndRenderTargetPtr render_target_;
|
||||
D2DTextFormatPtr fps_text_format_;
|
||||
D2DTextLayoutPtr fps_text_layout_;
|
||||
BitmapMap bitmap_cache_;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -412,7 +412,7 @@ namespace easy2d
|
|||
|
||||
if (!std::regex_match(str, duration_regex))
|
||||
{
|
||||
logs::Errorln("time::ParseDuration failed, invalid duration");
|
||||
logs::Errorln(L"time::ParseDuration failed, invalid duration");
|
||||
return Duration();
|
||||
}
|
||||
|
||||
|
|
@ -443,7 +443,7 @@ namespace easy2d
|
|||
|
||||
if (num_str.empty() || num_str == L".")
|
||||
{
|
||||
logs::Errorln("time::ParseDuration failed, invalid duration");
|
||||
logs::Errorln(L"time::ParseDuration failed, invalid duration");
|
||||
return Duration();
|
||||
}
|
||||
|
||||
|
|
@ -462,7 +462,7 @@ namespace easy2d
|
|||
|
||||
if (unit_map.find(unit_str) == unit_map.end())
|
||||
{
|
||||
logs::Errorln("time::ParseDuration failed, invalid duration");
|
||||
logs::Errorln(L"time::ParseDuration failed, invalid duration");
|
||||
return Duration();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,12 +44,12 @@ namespace easy2d
|
|||
|
||||
WindowImpl::~WindowImpl()
|
||||
{
|
||||
E2D_LOG("Destroying window");
|
||||
E2D_LOG(L"Destroying window");
|
||||
}
|
||||
|
||||
HRESULT WindowImpl::Init(String title, int width, int height, LPCWSTR icon, WNDPROC proc, bool debug)
|
||||
{
|
||||
E2D_LOG("Creating window");
|
||||
E2D_LOG(L"Creating window");
|
||||
|
||||
HINSTANCE hinstance = GetModuleHandle(nullptr);
|
||||
WNDCLASSEX wcex = { 0 };
|
||||
|
|
@ -235,7 +235,7 @@ namespace easy2d
|
|||
height = static_cast<int>(rect.bottom - rect.top);
|
||||
|
||||
if (max_width < width || max_height < height)
|
||||
logs::Warningln("The window is larger than screen!");
|
||||
logs::Warningln(L"The window is larger than screen!");
|
||||
|
||||
width = std::min(width, max_width);
|
||||
height = std::min(height, max_height);
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
|
||||
#include "core/noncopyable.hpp"
|
||||
#include "core/RefCounter.hpp"
|
||||
#include "core/intrusive/SmartPointer.hpp"
|
||||
#include "core/intrusive/SmartPtr.hpp"
|
||||
#include "core/intrusive/List.hpp"
|
||||
|
||||
#include "core/Object.h"
|
||||
|
|
@ -104,6 +104,7 @@
|
|||
#include "utils/File.h"
|
||||
#include "utils/Player.h"
|
||||
#include "utils/Transcoder.h"
|
||||
#include "utils/ResLoader.h"
|
||||
|
||||
|
||||
//
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ namespace easy2d
|
|||
return RandomReal(min, max);
|
||||
}
|
||||
|
||||
inline double Range(double min, double max)
|
||||
inline double Rand(double min, double max)
|
||||
{
|
||||
return RandomReal(min, max);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
Menu::Menu(Array<SpButton> const& buttons)
|
||||
Menu::Menu(Array<ButtonPtr> const& buttons)
|
||||
: enabled_(true)
|
||||
{
|
||||
for (const auto& button : buttons)
|
||||
|
|
@ -61,7 +61,7 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
void Menu::AddButton(SpButton const& button)
|
||||
void Menu::AddButton(ButtonPtr const& button)
|
||||
{
|
||||
if (button)
|
||||
{
|
||||
|
|
@ -71,7 +71,7 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
bool Menu::RemoveButton(SpButton const& button)
|
||||
bool Menu::RemoveButton(ButtonPtr const& button)
|
||||
{
|
||||
if (buttons_.empty())
|
||||
{
|
||||
|
|
@ -94,7 +94,7 @@ namespace easy2d
|
|||
return false;
|
||||
}
|
||||
|
||||
Array<SpButton> const& Menu::GetAllButtons() const
|
||||
Array<ButtonPtr> const& Menu::GetAllButtons() const
|
||||
{
|
||||
return buttons_;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace easy2d
|
|||
Menu();
|
||||
|
||||
explicit Menu(
|
||||
Array<SpButton> const& buttons /* 按钮数组 */
|
||||
Array<ButtonPtr> const& buttons /* 按钮数组 */
|
||||
);
|
||||
|
||||
// 获取菜单是否禁用
|
||||
|
|
@ -49,20 +49,20 @@ namespace easy2d
|
|||
|
||||
// 添加按钮
|
||||
void AddButton(
|
||||
SpButton const& button
|
||||
ButtonPtr const& button
|
||||
);
|
||||
|
||||
// 移除按钮
|
||||
bool RemoveButton(
|
||||
SpButton const& button
|
||||
ButtonPtr const& button
|
||||
);
|
||||
|
||||
// 获取所有按钮
|
||||
Array<SpButton> const& GetAllButtons() const;
|
||||
Array<ButtonPtr> const& GetAllButtons() const;
|
||||
|
||||
private:
|
||||
bool enabled_;
|
||||
Array<SpButton> buttons_;
|
||||
Array<ButtonPtr> buttons_;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -24,8 +24,6 @@
|
|||
|
||||
namespace easy2d
|
||||
{
|
||||
std::list<String> File::search_paths_;
|
||||
|
||||
File::File()
|
||||
: file_path_()
|
||||
{
|
||||
|
|
@ -34,7 +32,6 @@ namespace easy2d
|
|||
File::File(String const& file_name)
|
||||
: file_path_(file_name)
|
||||
{
|
||||
this->Open(file_name);
|
||||
}
|
||||
|
||||
File::~File()
|
||||
|
|
@ -46,35 +43,13 @@ namespace easy2d
|
|||
if (file_name.empty())
|
||||
return false;
|
||||
|
||||
auto FindFile = [](String const& path) -> bool
|
||||
{
|
||||
if (modules::Shlwapi().PathFileExistsW(path.c_str()))
|
||||
return true;
|
||||
return false;
|
||||
};
|
||||
|
||||
if (FindFile(file_name))
|
||||
{
|
||||
file_path_ = file_name;
|
||||
return true;
|
||||
}
|
||||
|
||||
for (const auto& path : search_paths_)
|
||||
{
|
||||
if (FindFile(path + file_name))
|
||||
{
|
||||
file_path_ = path + file_name;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return Exists();
|
||||
}
|
||||
|
||||
bool File::Exists() const
|
||||
{
|
||||
if (modules::Shlwapi().PathFileExistsW(file_path_.c_str()))
|
||||
return true;
|
||||
return false;
|
||||
return modules::Shlwapi::Get().PathFileExistsW(file_path_.c_str());
|
||||
}
|
||||
|
||||
String const& File::GetPath() const
|
||||
|
|
@ -101,7 +76,7 @@ namespace easy2d
|
|||
return false;
|
||||
}
|
||||
|
||||
File File::Extract(Resource& res, String const& dest_file_name)
|
||||
File File::Extract(Resource const& res, String const& dest_file_name)
|
||||
{
|
||||
File file;
|
||||
HANDLE file_handle = ::CreateFile(
|
||||
|
|
@ -136,25 +111,4 @@ namespace easy2d
|
|||
|
||||
return file;
|
||||
}
|
||||
|
||||
void File::AddSearchPath(String const& path)
|
||||
{
|
||||
String tmp = path;
|
||||
size_t pos = 0;
|
||||
while ((pos = tmp.find(L"/", pos)) != String::npos)
|
||||
{
|
||||
tmp.replace(pos, 1, L"\\");
|
||||
pos++;
|
||||
}
|
||||
|
||||
if (tmp.at(tmp.length() - 1) != L'\\')
|
||||
{
|
||||
tmp.append(L"\\");
|
||||
}
|
||||
auto iter = std::find(search_paths_.cbegin(), search_paths_.cend(), tmp);
|
||||
if (iter == search_paths_.cend())
|
||||
{
|
||||
search_paths_.push_front(tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -53,20 +53,13 @@ namespace easy2d
|
|||
// 获取文件扩展名
|
||||
String GetExtension() const;
|
||||
|
||||
// 释放资源到临时文件目录
|
||||
// 释放二进制资源到临时文件目录
|
||||
static File Extract(
|
||||
Resource& res, /* 资源 */
|
||||
Resource const& res, /* 资源 */
|
||||
String const& dest_file_name /* 目标文件名 */
|
||||
);
|
||||
|
||||
// 添加文件搜索路径
|
||||
static void AddSearchPath(
|
||||
String const& path
|
||||
);
|
||||
|
||||
protected:
|
||||
String file_path_;
|
||||
|
||||
static List<String> search_paths_;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ namespace easy2d
|
|||
if (musics_cache_.end() != musics_cache_.find(hash_code))
|
||||
return true;
|
||||
|
||||
SpMusic music = new (std::nothrow) Music();
|
||||
MusicPtr music = new (std::nothrow) Music();
|
||||
|
||||
if (music)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace easy2d
|
|||
class Player
|
||||
: protected Noncopyable
|
||||
{
|
||||
using MusicMap = Map<size_t, SpMusic>;
|
||||
using MusicMap = Map<size_t, MusicPtr>;
|
||||
|
||||
public:
|
||||
Player();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,114 @@
|
|||
// Copyright (c) 2016-2018 Easy2D - Nomango
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "ResLoader.h"
|
||||
#include "../core/Image.h"
|
||||
#include "../core/Frames.h"
|
||||
#include "../core/modules.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
namespace
|
||||
{
|
||||
String Search(LPCWSTR file_name, List<String> const& paths)
|
||||
{
|
||||
for (const auto& path : paths)
|
||||
{
|
||||
if (modules::Shlwapi::Get().PathFileExistsW((path + file_name).c_str()))
|
||||
{
|
||||
return path + file_name;
|
||||
}
|
||||
}
|
||||
return file_name;
|
||||
}
|
||||
}
|
||||
|
||||
void ResLoader::AddImage(String const& id, Resource const& image)
|
||||
{
|
||||
auto path = Search(image.GetFileName(), search_paths_);
|
||||
res_.insert(std::make_pair(id, ImagePtr(new Image(path.c_str()))));
|
||||
}
|
||||
|
||||
void ResLoader::AddFrames(String const& id, Array<Resource> const& images, Duration const& interval)
|
||||
{
|
||||
auto frames = FramesPtr(new Frames);
|
||||
frames->SetInterval(interval);
|
||||
|
||||
for (const auto& image : images)
|
||||
{
|
||||
auto path = Search(image.GetFileName(), search_paths_);
|
||||
frames->Add(ImagePtr(new Image(path.c_str())));
|
||||
}
|
||||
res_.insert(std::make_pair(id, frames));
|
||||
}
|
||||
|
||||
void ResLoader::AddObj(String const& id, ObjectPtr const& obj)
|
||||
{
|
||||
res_.insert(std::make_pair(id, obj));
|
||||
}
|
||||
|
||||
ImagePtr ResLoader::GetImage(String const & id) const
|
||||
{
|
||||
return Get<Image*>(id);
|
||||
}
|
||||
|
||||
FramesPtr ResLoader::GetFrames(String const & id) const
|
||||
{
|
||||
return Get<Frames*>(id);
|
||||
}
|
||||
|
||||
ObjectPtr ResLoader::GetObj(String const & id) const
|
||||
{
|
||||
return Get<Object*>(id);
|
||||
}
|
||||
|
||||
void ResLoader::Delete(String const & id)
|
||||
{
|
||||
res_.erase(id);
|
||||
}
|
||||
|
||||
void ResLoader::Destroy()
|
||||
{
|
||||
res_.clear();
|
||||
}
|
||||
|
||||
void ResLoader::AddSearchPath(String const & path)
|
||||
{
|
||||
String tmp = path;
|
||||
size_t pos = 0;
|
||||
while ((pos = tmp.find(L"/", pos)) != String::npos)
|
||||
{
|
||||
tmp.replace(pos, 1, L"\\");
|
||||
pos++;
|
||||
}
|
||||
|
||||
if (tmp.at(tmp.length() - 1) != L'\\')
|
||||
{
|
||||
tmp.append(L"\\");
|
||||
}
|
||||
|
||||
auto iter = std::find(search_paths_.cbegin(), search_paths_.cend(), tmp);
|
||||
if (iter == search_paths_.cend())
|
||||
{
|
||||
search_paths_.push_front(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -19,30 +19,46 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include "include-forwards.h"
|
||||
#include "../core/include-forwards.h"
|
||||
#include "../core/Resource.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
class ResLoader
|
||||
{
|
||||
public:
|
||||
//void Add(String const& id, SpImage const& image);
|
||||
void AddImage(String const& id, Resource const& image);
|
||||
|
||||
//void Add(String const& id, SpFrames const& frames);
|
||||
void AddFrames(String const& id, Array<Resource> const& images, Duration const& interval = 200);
|
||||
|
||||
//SpImage GetImage(String const& id);
|
||||
void AddObj(String const& id, ObjectPtr const& obj);
|
||||
|
||||
//SpFrames GetFrames(String const& id);
|
||||
ImagePtr GetImage(String const& id) const;
|
||||
|
||||
FramesPtr GetFrames(String const& id) const;
|
||||
|
||||
ObjectPtr GetObj(String const& id) const;
|
||||
|
||||
void Delete(String const& id);
|
||||
|
||||
void Destroy();
|
||||
|
||||
// Ìí¼Ó×ÊÔ´ËÑË÷·¾¶
|
||||
void AddSearchPath(
|
||||
String const& path
|
||||
);
|
||||
|
||||
template<typename T>
|
||||
T Get(String const& id) const
|
||||
auto Get(String const& id) const -> decltype(auto)
|
||||
{
|
||||
if (res_.find(id) == res_.end())
|
||||
auto iter = res_.find(id);
|
||||
if (iter == res_.end())
|
||||
return T{};
|
||||
return static_cast<T>(res_.at(id));
|
||||
return dynamic_cast<T>((*iter).second.Get());
|
||||
}
|
||||
|
||||
protected:
|
||||
UnorderedMap<String, void*> res_;
|
||||
UnorderedMap<String, ObjectPtr> res_;
|
||||
List<String> search_paths_;
|
||||
};
|
||||
}
|
||||
|
|
@ -51,9 +51,9 @@ namespace easy2d
|
|||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
SmartPointer<IMFSourceReader> reader;
|
||||
SmartPtr<IMFSourceReader> reader;
|
||||
|
||||
hr = modules::MediaFoundation().MFCreateSourceReaderFromURL(
|
||||
hr = modules::MediaFoundation::Get().MFCreateSourceReaderFromURL(
|
||||
file_path,
|
||||
nullptr,
|
||||
&reader
|
||||
|
|
@ -72,33 +72,33 @@ namespace easy2d
|
|||
HRESULT hr = S_OK;
|
||||
HINSTANCE hinstance = GetModuleHandle(nullptr);
|
||||
|
||||
SmartPointer<IStream> stream;
|
||||
SmartPointer<IMFByteStream> byte_stream;
|
||||
SmartPointer<IMFSourceReader> reader;
|
||||
SmartPtr<IStream> stream;
|
||||
SmartPtr<IMFByteStream> byte_stream;
|
||||
SmartPtr<IMFSourceReader> reader;
|
||||
|
||||
LPVOID buffer;
|
||||
DWORD buffer_size;
|
||||
if (!res.Load(buffer, buffer_size)) { return false; }
|
||||
|
||||
stream = modules::Shlwapi{}.SHCreateMemStream(
|
||||
stream = modules::Shlwapi::Get().SHCreateMemStream(
|
||||
static_cast<const BYTE*>(buffer),
|
||||
static_cast<UINT>(buffer_size)
|
||||
);
|
||||
|
||||
if (stream == nullptr)
|
||||
{
|
||||
logs::Errorln("SHCreateMemStream");
|
||||
logs::Errorln(L"SHCreateMemStream");
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = modules::MediaFoundation().MFCreateMFByteStreamOnStream(stream.Get(), &byte_stream);
|
||||
hr = modules::MediaFoundation::Get().MFCreateMFByteStreamOnStream(stream.Get(), &byte_stream);
|
||||
}
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = modules::MediaFoundation().MFCreateSourceReaderFromByteStream(
|
||||
hr = modules::MediaFoundation::Get().MFCreateSourceReaderFromByteStream(
|
||||
byte_stream.Get(),
|
||||
nullptr,
|
||||
&reader
|
||||
|
|
@ -118,10 +118,10 @@ namespace easy2d
|
|||
HRESULT hr = S_OK;
|
||||
DWORD max_stream_size = 0;
|
||||
|
||||
SmartPointer<IMFMediaType> partial_type;
|
||||
SmartPointer<IMFMediaType> uncompressed_type;
|
||||
SmartPtr<IMFMediaType> partial_type;
|
||||
SmartPtr<IMFMediaType> uncompressed_type;
|
||||
|
||||
hr = modules::MediaFoundation().MFCreateMediaType(&partial_type);
|
||||
hr = modules::MediaFoundation::Get().MFCreateMediaType(&partial_type);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
|
|
@ -165,7 +165,7 @@ namespace easy2d
|
|||
if (SUCCEEDED(hr))
|
||||
{
|
||||
UINT32 size = 0;
|
||||
hr = modules::MediaFoundation().MFCreateWaveFormatExFromMFMediaType(
|
||||
hr = modules::MediaFoundation::Get().MFCreateWaveFormatExFromMFMediaType(
|
||||
uncompressed_type.Get(),
|
||||
&wave_format_,
|
||||
&size,
|
||||
|
|
@ -199,12 +199,12 @@ namespace easy2d
|
|||
DWORD position = 0;
|
||||
BYTE* data = new (std::nothrow) BYTE[max_stream_size];
|
||||
|
||||
SmartPointer<IMFSample> sample;
|
||||
SmartPointer<IMFMediaBuffer> buffer;
|
||||
SmartPtr<IMFSample> sample;
|
||||
SmartPtr<IMFMediaBuffer> buffer;
|
||||
|
||||
if (data == nullptr)
|
||||
{
|
||||
logs::Errorln("Low memory");
|
||||
logs::Errorln(L"Low memory");
|
||||
hr = E_OUTOFMEMORY;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ namespace easy2d
|
|||
}
|
||||
else
|
||||
{
|
||||
logs::Errorln(HRESULT_FROM_WIN32(GetLastError()), "Wrong convert to WideChar code");
|
||||
logs::Errorln(HRESULT_FROM_WIN32(GetLastError()), L"Convert to WideChar code failed");
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
|
@ -66,7 +66,7 @@ namespace easy2d
|
|||
}
|
||||
else
|
||||
{
|
||||
logs::Errorln(HRESULT_FROM_WIN32(GetLastError()), ("Wrong convert to MultiByte code"));
|
||||
logs::Errorln(HRESULT_FROM_WIN32(GetLastError()), L"Convert to MultiByte code failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue