parent
cd2c112a98
commit
1de100c294
|
|
@ -62,7 +62,7 @@ namespace easy2d
|
||||||
return;
|
return;
|
||||||
|
|
||||||
UpdateActions(this, dt);
|
UpdateActions(this, dt);
|
||||||
UpdateTasks(dt);
|
UpdateTimers(dt);
|
||||||
|
|
||||||
if (cb_update_)
|
if (cb_update_)
|
||||||
cb_update_(dt);
|
cb_update_(dt);
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
#include "include-forwards.h"
|
#include "include-forwards.h"
|
||||||
#include "Transform.hpp"
|
#include "Transform.hpp"
|
||||||
#include "ActionManager.h"
|
#include "ActionManager.h"
|
||||||
#include "../base/TaskManager.h"
|
#include "../base/TimerManager.h"
|
||||||
#include "../base/EventDispatcher.h"
|
#include "../base/EventDispatcher.h"
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
|
|
@ -32,7 +32,7 @@ namespace easy2d
|
||||||
// ½Úµã
|
// ½Úµã
|
||||||
class E2D_API Node
|
class E2D_API Node
|
||||||
: public virtual Object
|
: public virtual Object
|
||||||
, public TaskManager
|
, public TimerManager
|
||||||
, public ActionManager
|
, public ActionManager
|
||||||
, public EventDispatcher
|
, public EventDispatcher
|
||||||
, public IntrusiveListItem<NodePtr>
|
, public IntrusiveListItem<NodePtr>
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,8 @@
|
||||||
<ClInclude Include="base\RefCounter.hpp" />
|
<ClInclude Include="base\RefCounter.hpp" />
|
||||||
<ClInclude Include="base\Resource.h" />
|
<ClInclude Include="base\Resource.h" />
|
||||||
<ClInclude Include="base\SmartPtr.hpp" />
|
<ClInclude Include="base\SmartPtr.hpp" />
|
||||||
<ClInclude Include="base\Task.h" />
|
<ClInclude Include="base\Timer.h" />
|
||||||
<ClInclude Include="base\TaskManager.h" />
|
<ClInclude Include="base\TimerManager.h" />
|
||||||
<ClInclude Include="base\time.h" />
|
<ClInclude Include="base\time.h" />
|
||||||
<ClInclude Include="base\window.h" />
|
<ClInclude Include="base\window.h" />
|
||||||
<ClInclude Include="common\Array.h" />
|
<ClInclude Include="common\Array.h" />
|
||||||
|
|
@ -101,8 +101,8 @@
|
||||||
<ClCompile Include="base\logs.cpp" />
|
<ClCompile Include="base\logs.cpp" />
|
||||||
<ClCompile Include="base\Object.cpp" />
|
<ClCompile Include="base\Object.cpp" />
|
||||||
<ClCompile Include="base\Resource.cpp" />
|
<ClCompile Include="base\Resource.cpp" />
|
||||||
<ClCompile Include="base\Task.cpp" />
|
<ClCompile Include="base\Timer.cpp" />
|
||||||
<ClCompile Include="base\TaskManager.cpp" />
|
<ClCompile Include="base\TimerManager.cpp" />
|
||||||
<ClCompile Include="base\time.cpp" />
|
<ClCompile Include="base\time.cpp" />
|
||||||
<ClCompile Include="base\window.cpp" />
|
<ClCompile Include="base\window.cpp" />
|
||||||
<ClCompile Include="platform\Application.cpp" />
|
<ClCompile Include="platform\Application.cpp" />
|
||||||
|
|
|
||||||
|
|
@ -153,12 +153,6 @@
|
||||||
<ClInclude Include="base\Resource.h">
|
<ClInclude Include="base\Resource.h">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="base\Task.h">
|
|
||||||
<Filter>base</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="base\TaskManager.h">
|
|
||||||
<Filter>base</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="base\time.h">
|
<ClInclude Include="base\time.h">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|
@ -243,6 +237,12 @@
|
||||||
<ClInclude Include="common\Json.h">
|
<ClInclude Include="common\Json.h">
|
||||||
<Filter>common</Filter>
|
<Filter>common</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="base\Timer.h">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="base\TimerManager.h">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="ui\Button.cpp">
|
<ClCompile Include="ui\Button.cpp">
|
||||||
|
|
@ -317,12 +317,6 @@
|
||||||
<ClCompile Include="base\Resource.cpp">
|
<ClCompile Include="base\Resource.cpp">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="base\Task.cpp">
|
|
||||||
<Filter>base</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="base\TaskManager.cpp">
|
|
||||||
<Filter>base</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="base\time.cpp">
|
<ClCompile Include="base\time.cpp">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
@ -368,5 +362,11 @@
|
||||||
<ClCompile Include="utils\DataUtil.cpp">
|
<ClCompile Include="utils\DataUtil.cpp">
|
||||||
<Filter>utils</Filter>
|
<Filter>utils</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="base\Timer.cpp">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="base\TimerManager.cpp">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -21,7 +21,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "../macros.h"
|
#include "../macros.h"
|
||||||
#include "../common/helper.h"
|
#include "../common/helper.h"
|
||||||
#include "../common/Json.h"
|
|
||||||
#include "RefCounter.hpp"
|
#include "RefCounter.hpp"
|
||||||
#include "SmartPtr.hpp"
|
#include "SmartPtr.hpp"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,130 +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 "TaskManager.h"
|
|
||||||
#include "../base/logs.h"
|
|
||||||
|
|
||||||
namespace easy2d
|
|
||||||
{
|
|
||||||
void TaskManager::UpdateTasks(Duration dt)
|
|
||||||
{
|
|
||||||
if (tasks_.IsEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
TaskPtr next;
|
|
||||||
for (auto task = tasks_.First(); task; task = next)
|
|
||||||
{
|
|
||||||
next = task->NextItem();
|
|
||||||
|
|
||||||
bool remove_after_update = false;
|
|
||||||
task->Update(dt, remove_after_update);
|
|
||||||
|
|
||||||
if (remove_after_update)
|
|
||||||
tasks_.Remove(task);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TaskManager::AddTask(TaskPtr const& task)
|
|
||||||
{
|
|
||||||
E2D_ASSERT(task && "AddTask failed, NULL pointer exception");
|
|
||||||
|
|
||||||
if (task)
|
|
||||||
{
|
|
||||||
task->Reset();
|
|
||||||
tasks_.PushBack(task);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TaskManager::StopTasks(String const& name)
|
|
||||||
{
|
|
||||||
if (tasks_.IsEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (auto task = tasks_.First().Get(); task; task = task->NextItem().Get())
|
|
||||||
{
|
|
||||||
if (task->IsName(name))
|
|
||||||
{
|
|
||||||
task->Stop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TaskManager::StartTasks(String const& name)
|
|
||||||
{
|
|
||||||
if (tasks_.IsEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (auto task = tasks_.First().Get(); task; task = task->NextItem().Get())
|
|
||||||
{
|
|
||||||
if (task->IsName(name))
|
|
||||||
{
|
|
||||||
task->Start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TaskManager::RemoveTasks(String const& name)
|
|
||||||
{
|
|
||||||
if (tasks_.IsEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
TaskPtr next;
|
|
||||||
for (auto task = tasks_.First(); task; task = next)
|
|
||||||
{
|
|
||||||
next = task->NextItem();
|
|
||||||
if (task->IsName(name))
|
|
||||||
{
|
|
||||||
tasks_.Remove(task);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TaskManager::StopAllTasks()
|
|
||||||
{
|
|
||||||
if (tasks_.IsEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (auto task = tasks_.First().Get(); task; task = task->NextItem().Get())
|
|
||||||
{
|
|
||||||
task->Stop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TaskManager::StartAllTasks()
|
|
||||||
{
|
|
||||||
if (tasks_.IsEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (auto task = tasks_.First().Get(); task; task = task->NextItem().Get())
|
|
||||||
{
|
|
||||||
task->Start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TaskManager::RemoveAllTasks()
|
|
||||||
{
|
|
||||||
tasks_.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
const TaskManager::Tasks & TaskManager::GetAllTasks() const
|
|
||||||
{
|
|
||||||
return tasks_;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -18,16 +18,16 @@
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#include "Task.h"
|
#include "Timer.h"
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
Task::Task(Callback const& func, String const& name)
|
Timer::Timer(Callback const& func, String const& name)
|
||||||
: Task(func, Duration{}, -1, name)
|
: Timer(func, Duration{}, -1, name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Task::Task(Callback const& func, Duration delay, int times, String const& name)
|
Timer::Timer(Callback const& func, Duration delay, int times, String const& name)
|
||||||
: running_(true)
|
: running_(true)
|
||||||
, run_times_(0)
|
, run_times_(0)
|
||||||
, total_times_(times)
|
, total_times_(times)
|
||||||
|
|
@ -38,17 +38,17 @@ namespace easy2d
|
||||||
SetName(name);
|
SetName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Task::Start()
|
void Timer::Start()
|
||||||
{
|
{
|
||||||
running_ = true;
|
running_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Task::Stop()
|
void Timer::Stop()
|
||||||
{
|
{
|
||||||
running_ = false;
|
running_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Task::Update(Duration dt, bool& remove_after_update)
|
void Timer::Update(Duration dt, bool& remove_after_update)
|
||||||
{
|
{
|
||||||
if (!running_)
|
if (!running_)
|
||||||
return;
|
return;
|
||||||
|
|
@ -80,13 +80,13 @@ namespace easy2d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Task::Reset()
|
void Timer::Reset()
|
||||||
{
|
{
|
||||||
delta_ = Duration{};
|
delta_ = Duration{};
|
||||||
run_times_ = 0;
|
run_times_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Task::IsRunning() const
|
bool Timer::IsRunning() const
|
||||||
{
|
{
|
||||||
return running_;
|
return running_;
|
||||||
}
|
}
|
||||||
|
|
@ -27,27 +27,27 @@
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
class TaskManager;
|
class TimerManager;
|
||||||
|
|
||||||
E2D_DECLARE_SMART_PTR(Task);
|
E2D_DECLARE_SMART_PTR(Timer);
|
||||||
|
|
||||||
// 定时任务
|
// 定时任务
|
||||||
class E2D_API Task
|
class E2D_API Timer
|
||||||
: public virtual Object
|
: public virtual Object
|
||||||
, protected IntrusiveListItem<TaskPtr>
|
, protected IntrusiveListItem<TimerPtr>
|
||||||
{
|
{
|
||||||
friend class TaskManager;
|
friend class TimerManager;
|
||||||
friend class IntrusiveList<TaskPtr>;
|
friend class IntrusiveList<TimerPtr>;
|
||||||
|
|
||||||
using Callback = std::function<void()>;
|
using Callback = std::function<void()>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Task(
|
explicit Timer(
|
||||||
Callback const& func, /* 执行函数 */
|
Callback const& func, /* 执行函数 */
|
||||||
String const& name = L"" /* 任务名称 */
|
String const& name = L"" /* 任务名称 */
|
||||||
);
|
);
|
||||||
|
|
||||||
explicit Task(
|
explicit Timer(
|
||||||
Callback const& func, /* 执行函数 */
|
Callback const& func, /* 执行函数 */
|
||||||
Duration delay, /* 时间间隔(秒) */
|
Duration delay, /* 时间间隔(秒) */
|
||||||
int times = -1, /* 执行次数(设 -1 为永久执行) */
|
int times = -1, /* 执行次数(设 -1 为永久执行) */
|
||||||
|
|
@ -0,0 +1,130 @@
|
||||||
|
// 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 "TimerManager.h"
|
||||||
|
#include "../base/logs.h"
|
||||||
|
|
||||||
|
namespace easy2d
|
||||||
|
{
|
||||||
|
void TimerManager::UpdateTimers(Duration dt)
|
||||||
|
{
|
||||||
|
if (timers_.IsEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
TimerPtr next;
|
||||||
|
for (auto timer = timers_.First(); timer; timer = next)
|
||||||
|
{
|
||||||
|
next = timer->NextItem();
|
||||||
|
|
||||||
|
bool remove_after_update = false;
|
||||||
|
timer->Update(dt, remove_after_update);
|
||||||
|
|
||||||
|
if (remove_after_update)
|
||||||
|
timers_.Remove(timer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TimerManager::AddTimer(TimerPtr const& timer)
|
||||||
|
{
|
||||||
|
E2D_ASSERT(timer && "AddTimer failed, NULL pointer exception");
|
||||||
|
|
||||||
|
if (timer)
|
||||||
|
{
|
||||||
|
timer->Reset();
|
||||||
|
timers_.PushBack(timer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TimerManager::StopTimers(String const& name)
|
||||||
|
{
|
||||||
|
if (timers_.IsEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (auto timer = timers_.First().Get(); timer; timer = timer->NextItem().Get())
|
||||||
|
{
|
||||||
|
if (timer->IsName(name))
|
||||||
|
{
|
||||||
|
timer->Stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TimerManager::StartTimers(String const& name)
|
||||||
|
{
|
||||||
|
if (timers_.IsEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (auto timer = timers_.First().Get(); timer; timer = timer->NextItem().Get())
|
||||||
|
{
|
||||||
|
if (timer->IsName(name))
|
||||||
|
{
|
||||||
|
timer->Start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TimerManager::RemoveTimers(String const& name)
|
||||||
|
{
|
||||||
|
if (timers_.IsEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
TimerPtr next;
|
||||||
|
for (auto timer = timers_.First(); timer; timer = next)
|
||||||
|
{
|
||||||
|
next = timer->NextItem();
|
||||||
|
if (timer->IsName(name))
|
||||||
|
{
|
||||||
|
timers_.Remove(timer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TimerManager::StopAllTimers()
|
||||||
|
{
|
||||||
|
if (timers_.IsEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (auto timer = timers_.First().Get(); timer; timer = timer->NextItem().Get())
|
||||||
|
{
|
||||||
|
timer->Stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TimerManager::StartAllTimers()
|
||||||
|
{
|
||||||
|
if (timers_.IsEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (auto timer = timers_.First().Get(); timer; timer = timer->NextItem().Get())
|
||||||
|
{
|
||||||
|
timer->Start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TimerManager::RemoveAllTimers()
|
||||||
|
{
|
||||||
|
timers_.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
const TimerManager::Timers & TimerManager::GetAllTimers() const
|
||||||
|
{
|
||||||
|
return timers_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -19,51 +19,51 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "Task.h"
|
#include "Timer.h"
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
class E2D_API TaskManager
|
class E2D_API TimerManager
|
||||||
{
|
{
|
||||||
using Tasks = IntrusiveList<TaskPtr>;
|
using Timers = IntrusiveList<TimerPtr>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// 添加任务
|
// 添加任务
|
||||||
void AddTask(
|
void AddTimer(
|
||||||
TaskPtr const& task
|
TimerPtr const& timer
|
||||||
);
|
);
|
||||||
|
|
||||||
// 启动任务
|
// 启动任务
|
||||||
void StartTasks(
|
void StartTimers(
|
||||||
String const& task_name
|
String const& timer_name
|
||||||
);
|
);
|
||||||
|
|
||||||
// 停止任务
|
// 停止任务
|
||||||
void StopTasks(
|
void StopTimers(
|
||||||
String const& task_name
|
String const& timer_name
|
||||||
);
|
);
|
||||||
|
|
||||||
// 移除任务
|
// 移除任务
|
||||||
void RemoveTasks(
|
void RemoveTimers(
|
||||||
String const& task_name
|
String const& timer_name
|
||||||
);
|
);
|
||||||
|
|
||||||
// 启动所有任务
|
// 启动所有任务
|
||||||
void StartAllTasks();
|
void StartAllTimers();
|
||||||
|
|
||||||
// 停止所有任务
|
// 停止所有任务
|
||||||
void StopAllTasks();
|
void StopAllTimers();
|
||||||
|
|
||||||
// 移除所有任务
|
// 移除所有任务
|
||||||
void RemoveAllTasks();
|
void RemoveAllTimers();
|
||||||
|
|
||||||
// 获取所有任务
|
// 获取所有任务
|
||||||
const Tasks& GetAllTasks() const;
|
const Timers& GetAllTimers() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void UpdateTasks(Duration dt);
|
void UpdateTimers(Duration dt);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Tasks tasks_;
|
Timers timers_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
1866
easy2d/common/Json.h
1866
easy2d/common/Json.h
File diff suppressed because it is too large
Load Diff
|
|
@ -1080,7 +1080,7 @@ namespace easy2d
|
||||||
using size_type = String::size_type;
|
using size_type = String::size_type;
|
||||||
using traits = String::char_traits;
|
using traits = String::char_traits;
|
||||||
|
|
||||||
const typename ostream::sentry ok(os);
|
const ostream::sentry ok(os);
|
||||||
std::ios_base::iostate state = std::ios_base::goodbit;
|
std::ios_base::iostate state = std::ios_base::goodbit;
|
||||||
|
|
||||||
if (!ok)
|
if (!ok)
|
||||||
|
|
@ -1142,7 +1142,7 @@ namespace easy2d
|
||||||
using traits = String::char_traits;
|
using traits = String::char_traits;
|
||||||
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
const typename istream::sentry ok(is);
|
const istream::sentry ok(is);
|
||||||
std::ios_base::iostate state = std::ios_base::goodbit;
|
std::ios_base::iostate state = std::ios_base::goodbit;
|
||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,4 @@ namespace easy2d
|
||||||
|
|
||||||
template<typename _Kty, typename _Ty, typename... _Args>
|
template<typename _Kty, typename _Ty, typename... _Args>
|
||||||
using UnorderedMap = std::unordered_map<_Kty, _Ty, _Args...>;
|
using UnorderedMap = std::unordered_map<_Kty, _Ty, _Args...>;
|
||||||
|
|
||||||
template <bool _Boolean, typename _Ty = void>
|
|
||||||
using enable_if_t = typename std::enable_if<_Boolean, _Ty>::type;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,8 +71,8 @@
|
||||||
#include "base/Event.hpp"
|
#include "base/Event.hpp"
|
||||||
#include "base/EventListener.h"
|
#include "base/EventListener.h"
|
||||||
#include "base/EventDispatcher.h"
|
#include "base/EventDispatcher.h"
|
||||||
#include "base/Task.h"
|
#include "base/Timer.h"
|
||||||
#include "base/TaskManager.h"
|
#include "base/TimerManager.h"
|
||||||
|
|
||||||
#include "2d/Font.hpp"
|
#include "2d/Font.hpp"
|
||||||
#include "2d/Color.h"
|
#include "2d/Color.h"
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@ class DemoApp
|
||||||
public:
|
public:
|
||||||
DemoApp()
|
DemoApp()
|
||||||
{
|
{
|
||||||
ShowConsole();
|
|
||||||
// 使用 Audio 组件
|
// 使用 Audio 组件
|
||||||
Use(&Audio::Instance());
|
Use(&Audio::Instance());
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue