add Events and EventDispatcher
This commit is contained in:
parent
bf25bd1d41
commit
406ea51b57
|
|
@ -44,7 +44,7 @@ namespace easy2d
|
||||||
void ActionManager::AddAction(spAction const& action)
|
void ActionManager::AddAction(spAction const& action)
|
||||||
{
|
{
|
||||||
if (!action)
|
if (!action)
|
||||||
logs::Warningln("Node::RunAction failed, action is nullptr");
|
logs::Warningln("AddAction failed, action is nullptr");
|
||||||
|
|
||||||
if (action)
|
if (action)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,22 @@ namespace easy2d
|
||||||
Round = 2 /* Ô²½Ç */
|
Round = 2 /* Ô²½Ç */
|
||||||
};
|
};
|
||||||
|
|
||||||
// 囚徒囚峙
|
// 夕蚊奉來
|
||||||
|
struct LayerProperties
|
||||||
|
{
|
||||||
|
Rect area;
|
||||||
|
float opacity;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 報炎囚峙
|
||||||
|
enum class MouseButton : int
|
||||||
|
{
|
||||||
|
Left = VK_LBUTTON, // 報炎恣囚
|
||||||
|
Right = VK_RBUTTON, // 報炎嘔囚
|
||||||
|
Middle = VK_MBUTTON // 報炎嶄囚
|
||||||
|
};
|
||||||
|
|
||||||
|
// 梓囚囚峙
|
||||||
enum class KeyCode : int
|
enum class KeyCode : int
|
||||||
{
|
{
|
||||||
Unknown = 0,
|
Unknown = 0,
|
||||||
|
|
@ -122,19 +137,4 @@ namespace easy2d
|
||||||
F11,
|
F11,
|
||||||
F12,
|
F12,
|
||||||
};
|
};
|
||||||
|
|
||||||
// 報炎囚峙
|
|
||||||
enum class MouseCode : int
|
|
||||||
{
|
|
||||||
Left = VK_LBUTTON, /* 報炎恣囚 */
|
|
||||||
Right = VK_RBUTTON, /* 報炎嘔囚 */
|
|
||||||
Middle = VK_MBUTTON /* 報炎嶄囚 */
|
|
||||||
};
|
|
||||||
|
|
||||||
// 夕蚊奉來
|
|
||||||
struct LayerProperties
|
|
||||||
{
|
|
||||||
Rect area;
|
|
||||||
float opacity;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ namespace easy2d
|
||||||
, stroke_width_(1.0f)
|
, stroke_width_(1.0f)
|
||||||
{
|
{
|
||||||
ThrowIfFailed(
|
ThrowIfFailed(
|
||||||
devices::Graphics::Instance()->CreateBitmapRenderTarget(render_target_)
|
Graphics::Instance()->CreateBitmapRenderTarget(render_target_)
|
||||||
);
|
);
|
||||||
|
|
||||||
auto properties = D2D1::BrushProperties();
|
auto properties = D2D1::BrushProperties();
|
||||||
|
|
@ -105,7 +105,7 @@ namespace easy2d
|
||||||
|
|
||||||
if (bitmap_cached_)
|
if (bitmap_cached_)
|
||||||
{
|
{
|
||||||
devices::Graphics::Instance()->DrawBitmap(bitmap_cached_);
|
Graphics::Instance()->DrawBitmap(bitmap_cached_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,49 +20,37 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
#include "BaseTypes.hpp"
|
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
// 按键消息
|
typedef UINT EventType;
|
||||||
class KeyEvent
|
|
||||||
|
class Event
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// 按键消息类型
|
Event(EventType type) : type(type), has_target(false) {}
|
||||||
enum class Type : int
|
|
||||||
{
|
EventType type;
|
||||||
Down = 0x0100, // 按下
|
bool has_target;
|
||||||
Up // 抬起
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
class SysEvent
|
||||||
explicit KeyEvent(
|
: public Event
|
||||||
UINT message,
|
|
||||||
WPARAM w_param,
|
|
||||||
LPARAM l_param
|
|
||||||
);
|
|
||||||
|
|
||||||
// 获取事件类型
|
|
||||||
KeyEvent::Type GetType() const;
|
|
||||||
|
|
||||||
// 获取按键键值
|
|
||||||
KeyCode GetCode() const;
|
|
||||||
|
|
||||||
// 获取按键次数
|
|
||||||
int GetCount() const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
UINT message_;
|
|
||||||
WPARAM w_param_;
|
|
||||||
LPARAM l_param_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// 按键消息处理接口
|
|
||||||
class KeyEventHandler
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// 处理按键消息
|
enum Type
|
||||||
virtual void Handle(KeyEvent e) = 0;
|
{
|
||||||
|
First = WM_NULL,
|
||||||
|
|
||||||
|
WindowActivate, // 窗口获得焦点
|
||||||
|
WindowDeavtivate, // 窗口失去焦点
|
||||||
|
WindowClose, // 关闭窗口
|
||||||
|
|
||||||
|
Last
|
||||||
|
};
|
||||||
|
|
||||||
|
SysEvent(EventType type) : Event(type) {}
|
||||||
|
|
||||||
|
static bool Check(Event* e) { return e->type > Type::First && e->type < Type::Last; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,135 @@
|
||||||
|
// 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 "EventDispatcher.h"
|
||||||
|
#include "logs.h"
|
||||||
|
|
||||||
|
namespace easy2d
|
||||||
|
{
|
||||||
|
void EventDispatcher::DispatchEvent(Event* e)
|
||||||
|
{
|
||||||
|
if (listeners_.IsEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
spEventListener next;
|
||||||
|
for (auto listener = listeners_.First(); listener; listener = next)
|
||||||
|
{
|
||||||
|
next = listener->NextItem();
|
||||||
|
|
||||||
|
if (listener->type_ == e->type)
|
||||||
|
{
|
||||||
|
listener->callback_(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventDispatcher::AddListener(spEventListener const & listener)
|
||||||
|
{
|
||||||
|
if (!listener)
|
||||||
|
logs::Warningln("AddListener failed, action is nullptr");
|
||||||
|
|
||||||
|
if (listener)
|
||||||
|
{
|
||||||
|
listeners_.PushBack(EventListener::ItemType(listener));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventDispatcher::AddListener(EventType type, EventCallback callback, String const& name)
|
||||||
|
{
|
||||||
|
spEventListener listener = new EventListener(type, callback, name);
|
||||||
|
if (listener)
|
||||||
|
{
|
||||||
|
listeners_.PushBack(EventListener::ItemType(listener));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventDispatcher::StartListeners(String const & listener_name)
|
||||||
|
{
|
||||||
|
for (auto listener = listeners_.First(); listener; listener = listener->NextItem())
|
||||||
|
{
|
||||||
|
if (listener->GetName() == listener_name)
|
||||||
|
{
|
||||||
|
listener->Start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventDispatcher::StopListeners(String const & listener_name)
|
||||||
|
{
|
||||||
|
for (auto listener = listeners_.First(); listener; listener = listener->NextItem())
|
||||||
|
{
|
||||||
|
if (listener->GetName() == listener_name)
|
||||||
|
{
|
||||||
|
listener->Stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventDispatcher::RemoveListeners(String const & listener_name)
|
||||||
|
{
|
||||||
|
spEventListener next;
|
||||||
|
for (auto listener = listeners_.First(); listener; listener = next)
|
||||||
|
{
|
||||||
|
next = listener->NextItem();
|
||||||
|
|
||||||
|
if (listener->GetName() == listener_name)
|
||||||
|
{
|
||||||
|
listeners_.Remove(listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventDispatcher::StartListeners(EventType type)
|
||||||
|
{
|
||||||
|
for (auto listener = listeners_.First(); listener; listener = listener->NextItem())
|
||||||
|
{
|
||||||
|
if (listener->type_ == type)
|
||||||
|
{
|
||||||
|
listener->Start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventDispatcher::StopListeners(EventType type)
|
||||||
|
{
|
||||||
|
for (auto listener = listeners_.First(); listener; listener = listener->NextItem())
|
||||||
|
{
|
||||||
|
if (listener->type_ == type)
|
||||||
|
{
|
||||||
|
listener->Stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventDispatcher::RemoveListeners(EventType type)
|
||||||
|
{
|
||||||
|
spEventListener next;
|
||||||
|
for (auto listener = listeners_.First(); listener; listener = next)
|
||||||
|
{
|
||||||
|
next = listener->NextItem();
|
||||||
|
|
||||||
|
if (listener->type_ == type)
|
||||||
|
{
|
||||||
|
listeners_.Remove(listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "EventListener.h"
|
||||||
|
|
||||||
|
namespace easy2d
|
||||||
|
{
|
||||||
|
class EventDispatcher
|
||||||
|
{
|
||||||
|
using Listeners = intrusive::List<spEventListener>;
|
||||||
|
|
||||||
|
public:
|
||||||
|
// 添加监听器
|
||||||
|
void AddListener(
|
||||||
|
spEventListener const& listener
|
||||||
|
);
|
||||||
|
|
||||||
|
// 添加监听器
|
||||||
|
void AddListener(
|
||||||
|
EventType type,
|
||||||
|
EventCallback callback,
|
||||||
|
String const& name = L""
|
||||||
|
);
|
||||||
|
|
||||||
|
// 启动监听器
|
||||||
|
void StartListeners(
|
||||||
|
String const& listener_name
|
||||||
|
);
|
||||||
|
|
||||||
|
// 停止监听器
|
||||||
|
void StopListeners(
|
||||||
|
String const& listener_name
|
||||||
|
);
|
||||||
|
|
||||||
|
// 移除监听器
|
||||||
|
void RemoveListeners(
|
||||||
|
String const& listener_name
|
||||||
|
);
|
||||||
|
|
||||||
|
// 启动监听器
|
||||||
|
void StartListeners(
|
||||||
|
EventType type
|
||||||
|
);
|
||||||
|
|
||||||
|
// 停止监听器
|
||||||
|
void StopListeners(
|
||||||
|
EventType type
|
||||||
|
);
|
||||||
|
|
||||||
|
// 移除监听器
|
||||||
|
void RemoveListeners(
|
||||||
|
EventType type
|
||||||
|
);
|
||||||
|
|
||||||
|
virtual void DispatchEvent(Event* e);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Listeners listeners_;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "EventListener.h"
|
||||||
|
|
||||||
|
namespace easy2d
|
||||||
|
{
|
||||||
|
EventListener::EventListener(EventType type, EventCallback const & callback, String const & name)
|
||||||
|
: type_(type)
|
||||||
|
, callback_(callback)
|
||||||
|
, name_(name)
|
||||||
|
, running_(true)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
EventListener::~EventListener()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventListener::Start()
|
||||||
|
{
|
||||||
|
running_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventListener::Stop()
|
||||||
|
{
|
||||||
|
running_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EventListener::IsRunning() const
|
||||||
|
{
|
||||||
|
return running_;
|
||||||
|
}
|
||||||
|
|
||||||
|
String const & EventListener::GetName() const
|
||||||
|
{
|
||||||
|
return name_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventListener::SetName(String const & name)
|
||||||
|
{
|
||||||
|
name_ = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,65 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "base.hpp"
|
||||||
|
#include "intrusive/List.hpp"
|
||||||
|
#include "Event.hpp"
|
||||||
|
|
||||||
|
namespace easy2d
|
||||||
|
{
|
||||||
|
typedef std::function<void(Event*)> EventCallback;
|
||||||
|
|
||||||
|
|
||||||
|
class EventDispatcher;
|
||||||
|
|
||||||
|
class EventListener
|
||||||
|
: public RefCounter
|
||||||
|
, protected intrusive::ListItem<spEventListener>
|
||||||
|
{
|
||||||
|
friend class EventDispatcher;
|
||||||
|
friend class intrusive::List<spEventListener>;
|
||||||
|
|
||||||
|
public:
|
||||||
|
EventListener(
|
||||||
|
EventType type,
|
||||||
|
EventCallback const& callback,
|
||||||
|
String const& name = L""
|
||||||
|
);
|
||||||
|
|
||||||
|
virtual ~EventListener();
|
||||||
|
|
||||||
|
void Start();
|
||||||
|
|
||||||
|
void Stop();
|
||||||
|
|
||||||
|
void SetName(String const& name);
|
||||||
|
|
||||||
|
bool IsRunning() const;
|
||||||
|
|
||||||
|
String const& GetName() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool running_;
|
||||||
|
String name_;
|
||||||
|
EventType type_;
|
||||||
|
EventCallback callback_;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -23,26 +23,24 @@
|
||||||
#include "modules.h"
|
#include "modules.h"
|
||||||
#include "Factory.h"
|
#include "Factory.h"
|
||||||
#include "Scene.h"
|
#include "Scene.h"
|
||||||
#include "Transition.h"
|
|
||||||
#include "Debuger.h"
|
#include "Debuger.h"
|
||||||
|
#include "Transition.h"
|
||||||
|
#include "KeyEvent.hpp"
|
||||||
|
#include "MouseEvent.hpp"
|
||||||
#include "../math/Matrix.hpp"
|
#include "../math/Matrix.hpp"
|
||||||
#include <thread>
|
#include <windowsx.h>
|
||||||
#include <imm.h>
|
#include <imm.h>
|
||||||
|
|
||||||
#pragma comment (lib ,"imm32.lib")
|
#pragma comment (lib ,"imm32.lib")
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
Game::Game()
|
Game::Game()
|
||||||
: initialized_(false)
|
: active_(false)
|
||||||
, window_inactived_(false)
|
, debug_(false)
|
||||||
, curr_scene_(nullptr)
|
, curr_scene_(nullptr)
|
||||||
, next_scene_(nullptr)
|
, next_scene_(nullptr)
|
||||||
, transition_(nullptr)
|
, transition_(nullptr)
|
||||||
, window_(nullptr)
|
|
||||||
, graphics_(nullptr)
|
|
||||||
, input_(nullptr)
|
|
||||||
, audio_(nullptr)
|
|
||||||
, debug_enabled_(false)
|
|
||||||
, time_scale_(1.f)
|
, time_scale_(1.f)
|
||||||
{
|
{
|
||||||
::CoInitialize(nullptr);
|
::CoInitialize(nullptr);
|
||||||
|
|
@ -61,52 +59,44 @@ namespace easy2d
|
||||||
|
|
||||||
void Game::Init(const Options& options)
|
void Game::Init(const Options& options)
|
||||||
{
|
{
|
||||||
if (initialized_)
|
debug_ = options.debug;
|
||||||
return;
|
|
||||||
|
|
||||||
debug_enabled_ = options.debug;
|
|
||||||
|
|
||||||
window_ = Window::Instance();
|
|
||||||
graphics_ = devices::Graphics::Instance();
|
|
||||||
input_ = devices::Input::Instance();
|
|
||||||
audio_ = devices::Audio::Instance();
|
|
||||||
|
|
||||||
ThrowIfFailed(
|
ThrowIfFailed(
|
||||||
Factory::Instance()->Init(debug_enabled_)
|
Factory::Instance()->Init(debug_)
|
||||||
);
|
);
|
||||||
|
|
||||||
ThrowIfFailed(
|
ThrowIfFailed(
|
||||||
window_->Init(
|
Window::Instance()->Init(
|
||||||
options.title,
|
options.title,
|
||||||
options.width,
|
options.width,
|
||||||
options.height,
|
options.height,
|
||||||
options.icon,
|
options.icon,
|
||||||
Game::WndProc,
|
Game::WndProc,
|
||||||
debug_enabled_
|
debug_
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
HWND hwnd = window_->GetHandle();
|
HWND hwnd = Window::Instance()->GetHandle();
|
||||||
|
|
||||||
ThrowIfFailed(
|
ThrowIfFailed(
|
||||||
graphics_->Init(
|
Graphics::Instance()->Init(
|
||||||
hwnd,
|
hwnd,
|
||||||
options.vsync,
|
options.vsync,
|
||||||
debug_enabled_
|
debug_
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
ThrowIfFailed(
|
ThrowIfFailed(
|
||||||
input_->Init(
|
Input::Instance()->Init(
|
||||||
hwnd,
|
hwnd,
|
||||||
window_->GetContentScaleX(),
|
Window::Instance()->GetContentScaleX(),
|
||||||
window_->GetContentScaleY(),
|
Window::Instance()->GetContentScaleY(),
|
||||||
debug_enabled_
|
debug_
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
ThrowIfFailed(
|
ThrowIfFailed(
|
||||||
audio_->Init(debug_enabled_)
|
Audio::Instance()->Init(debug_)
|
||||||
);
|
);
|
||||||
|
|
||||||
// disable imm
|
// disable imm
|
||||||
|
|
@ -114,7 +104,7 @@ namespace easy2d
|
||||||
|
|
||||||
// show console if debug mode enabled
|
// show console if debug mode enabled
|
||||||
HWND console = ::GetConsoleWindow();
|
HWND console = ::GetConsoleWindow();
|
||||||
if (debug_enabled_ && !console)
|
if (debug_ && !console)
|
||||||
{
|
{
|
||||||
if (::AllocConsole())
|
if (::AllocConsole())
|
||||||
{
|
{
|
||||||
|
|
@ -125,7 +115,7 @@ namespace easy2d
|
||||||
freopen_s(&stderrStream, "conout$", "w+t", stderr);
|
freopen_s(&stderrStream, "conout$", "w+t", stderr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!debug_enabled_ && console)
|
else if (!debug_ && console)
|
||||||
{
|
{
|
||||||
::ShowWindow(console, SW_HIDE);
|
::ShowWindow(console, SW_HIDE);
|
||||||
}
|
}
|
||||||
|
|
@ -139,17 +129,16 @@ namespace easy2d
|
||||||
|
|
||||||
// use Game instance in message loop
|
// use Game instance in message loop
|
||||||
::SetWindowLongW(hwnd, GWLP_USERDATA, PtrToUlong(this));
|
::SetWindowLongW(hwnd, GWLP_USERDATA, PtrToUlong(this));
|
||||||
|
|
||||||
initialized_ = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::Run()
|
void Game::Run()
|
||||||
{
|
{
|
||||||
if (!initialized_)
|
HWND hwnd = Window::Instance()->GetHandle();
|
||||||
return;
|
|
||||||
|
|
||||||
::ShowWindow(window_->GetHandle(), SW_SHOWNORMAL);
|
if (hwnd)
|
||||||
::UpdateWindow(window_->GetHandle());
|
{
|
||||||
|
::ShowWindow(hwnd, SW_SHOWNORMAL);
|
||||||
|
::UpdateWindow(hwnd);
|
||||||
|
|
||||||
MSG msg = {};
|
MSG msg = {};
|
||||||
while (::GetMessageW(&msg, nullptr, 0, 0))
|
while (::GetMessageW(&msg, nullptr, 0, 0))
|
||||||
|
|
@ -158,35 +147,29 @@ namespace easy2d
|
||||||
::DispatchMessageW(&msg);
|
::DispatchMessageW(&msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Game::Quit()
|
void Game::Quit()
|
||||||
{
|
{
|
||||||
if (window_)
|
Window::Instance()->Destroy();
|
||||||
::DestroyWindow(window_->GetHandle());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Game::EnterScene(spScene const & scene)
|
void Game::EnterScene(spScene const & scene)
|
||||||
{
|
{
|
||||||
if (!scene)
|
if (!scene)
|
||||||
{
|
|
||||||
logs::Warningln("Game::EnterScene failed, scene is nullptr");
|
logs::Warningln("Game::EnterScene failed, scene is nullptr");
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (curr_scene_ == scene ||
|
if (curr_scene_ == scene || next_scene_ == scene)
|
||||||
next_scene_ == scene)
|
return;
|
||||||
return false;
|
|
||||||
|
|
||||||
next_scene_ = scene;
|
next_scene_ = scene;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Game::EnterScene(spScene const& scene, spTransition const& transition)
|
void Game::EnterScene(spScene const& scene, spTransition const& transition)
|
||||||
{
|
{
|
||||||
if (!EnterScene(scene))
|
EnterScene(scene);
|
||||||
return false;
|
|
||||||
|
|
||||||
if (transition)
|
if (transition && next_scene_)
|
||||||
{
|
{
|
||||||
if (transition_)
|
if (transition_)
|
||||||
{
|
{
|
||||||
|
|
@ -195,7 +178,6 @@ namespace easy2d
|
||||||
transition_ = transition;
|
transition_ = transition;
|
||||||
transition_->Init(curr_scene_, next_scene_);
|
transition_->Init(curr_scene_, next_scene_);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
spScene const& Game::GetCurrentScene()
|
spScene const& Game::GetCurrentScene()
|
||||||
|
|
@ -216,7 +198,7 @@ namespace easy2d
|
||||||
const auto dt = (now - last) * time_scale_;
|
const auto dt = (now - last) * time_scale_;
|
||||||
last = now;
|
last = now;
|
||||||
|
|
||||||
input_->Update();
|
Input::Instance()->Update();
|
||||||
|
|
||||||
if (curr_scene_)
|
if (curr_scene_)
|
||||||
curr_scene_->Update(dt);
|
curr_scene_->Update(dt);
|
||||||
|
|
@ -224,7 +206,7 @@ namespace easy2d
|
||||||
if (next_scene_)
|
if (next_scene_)
|
||||||
next_scene_->Update(dt);
|
next_scene_->Update(dt);
|
||||||
|
|
||||||
if (debug_enabled_)
|
if (debug_)
|
||||||
Debuger::Instance()->Update(dt);
|
Debuger::Instance()->Update(dt);
|
||||||
|
|
||||||
if (transition_)
|
if (transition_)
|
||||||
|
|
@ -251,12 +233,12 @@ namespace easy2d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::Render()
|
void Game::Render(HWND hwnd)
|
||||||
{
|
{
|
||||||
auto graphics = devices::Graphics::Instance();
|
auto graphics = Graphics::Instance();
|
||||||
|
|
||||||
ThrowIfFailed(
|
ThrowIfFailed(
|
||||||
graphics->BeginDraw(window_->GetHandle())
|
graphics->BeginDraw(hwnd)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (transition_)
|
if (transition_)
|
||||||
|
|
@ -268,7 +250,7 @@ namespace easy2d
|
||||||
curr_scene_->Render();
|
curr_scene_->Render();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug_enabled_)
|
if (debug_)
|
||||||
{
|
{
|
||||||
graphics->SetTransform(math::Matrix());
|
graphics->SetTransform(math::Matrix());
|
||||||
graphics->SetOpacity(1.f);
|
graphics->SetOpacity(1.f);
|
||||||
|
|
@ -290,36 +272,13 @@ namespace easy2d
|
||||||
graphics->EndDraw()
|
graphics->EndDraw()
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!window_inactived_)
|
if (active_)
|
||||||
::InvalidateRect(window_->GetHandle(), NULL, FALSE);
|
::InvalidateRect(hwnd, NULL, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::Dispatch(MouseEvent const & e)
|
bool Game::HandleMessage(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||||
{
|
{
|
||||||
if (transition_)
|
bool unhandled = false;
|
||||||
return;
|
|
||||||
|
|
||||||
if (curr_scene_)
|
|
||||||
curr_scene_->Dispatch(e, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Game::Dispatch(KeyEvent const & e)
|
|
||||||
{
|
|
||||||
if (transition_)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (curr_scene_)
|
|
||||||
curr_scene_->Dispatch(e, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
LRESULT CALLBACK Game::WndProc(HWND hwnd, UINT msg, WPARAM w_param, LPARAM l_param)
|
|
||||||
{
|
|
||||||
LRESULT result = 0;
|
|
||||||
bool was_handled = false;
|
|
||||||
|
|
||||||
Game * game = reinterpret_cast<Game*>(
|
|
||||||
static_cast<LONG_PTR>(::GetWindowLongW(hwnd, GWLP_USERDATA))
|
|
||||||
);
|
|
||||||
|
|
||||||
switch (msg)
|
switch (msg)
|
||||||
{
|
{
|
||||||
|
|
@ -328,95 +287,184 @@ namespace easy2d
|
||||||
PAINTSTRUCT ps;
|
PAINTSTRUCT ps;
|
||||||
::BeginPaint(hwnd, &ps);
|
::BeginPaint(hwnd, &ps);
|
||||||
|
|
||||||
game->Update();
|
Update();
|
||||||
game->Render();
|
Render(hwnd);
|
||||||
|
|
||||||
::EndPaint(hwnd, &ps);
|
::EndPaint(hwnd, &ps);
|
||||||
}
|
}
|
||||||
result = 0;
|
|
||||||
was_handled = true;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
case WM_LBUTTONDBLCLK:
|
//case WM_LBUTTONDBLCLK:
|
||||||
case WM_MBUTTONUP:
|
//case WM_MBUTTONUP:
|
||||||
case WM_MBUTTONDOWN:
|
//case WM_MBUTTONDOWN:
|
||||||
case WM_MBUTTONDBLCLK:
|
//case WM_MBUTTONDBLCLK:
|
||||||
case WM_RBUTTONUP:
|
case WM_RBUTTONUP:
|
||||||
case WM_RBUTTONDOWN:
|
case WM_RBUTTONDOWN:
|
||||||
case WM_RBUTTONDBLCLK:
|
//case WM_RBUTTONDBLCLK:
|
||||||
case WM_MOUSEMOVE:
|
case WM_MOUSEMOVE:
|
||||||
case WM_MOUSEWHEEL:
|
case WM_MOUSEWHEEL:
|
||||||
{
|
{
|
||||||
game->Dispatch(MouseEvent(msg, w_param, l_param));
|
float x = GET_X_LPARAM(lparam) * Window::Instance()->GetContentScaleX();
|
||||||
|
float y = GET_Y_LPARAM(lparam) * Window::Instance()->GetContentScaleY();
|
||||||
|
float wheel_delta = 0.f;
|
||||||
|
|
||||||
|
MouseEvent::Type type;
|
||||||
|
if (msg == WM_LBUTTONDOWN || msg == WM_RBUTTONDOWN)
|
||||||
|
type = MouseEvent::Down;
|
||||||
|
else if (msg == WM_LBUTTONUP || msg == WM_RBUTTONUP)
|
||||||
|
type = MouseEvent::Up;
|
||||||
|
else if (msg == WM_MOUSEMOVE)
|
||||||
|
type = MouseEvent::Move;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
type = MouseEvent::Wheel;
|
||||||
|
wheel_delta = GET_WHEEL_DELTA_WPARAM(wparam) / 120.f;
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseEvent event(type, x, y, wheel_delta);
|
||||||
|
|
||||||
|
if (wparam & MK_LBUTTON || wparam & MK_RBUTTON)
|
||||||
|
event.button_down = true;
|
||||||
|
|
||||||
|
Dispatch(&event);
|
||||||
}
|
}
|
||||||
result = 0;
|
|
||||||
was_handled = true;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_KEYDOWN:
|
case WM_KEYDOWN:
|
||||||
case WM_KEYUP:
|
case WM_KEYUP:
|
||||||
{
|
{
|
||||||
game->Dispatch(KeyEvent(msg, w_param, l_param));
|
KeyEvent event(msg, KeyCode(wparam));
|
||||||
}
|
Dispatch(&event);
|
||||||
result = 0;
|
|
||||||
was_handled = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_SIZE:
|
|
||||||
{
|
|
||||||
if (SIZE_MAXHIDE == w_param || SIZE_MINIMIZED == w_param)
|
|
||||||
game->window_inactived_ = true;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
game->window_inactived_ = false;
|
|
||||||
::InvalidateRect(hwnd, nullptr, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
UINT width = LOWORD(l_param);
|
|
||||||
UINT height = HIWORD(l_param);
|
|
||||||
|
|
||||||
// 如果程序接收到一个 WM_SIZE 消息,这个方法将调整渲染
|
|
||||||
// 目标的大小。它可能会调用失败,但是这里可以忽略有可能的
|
|
||||||
// 错误,因为这个错误将在下一次调用 EndDraw 时产生
|
|
||||||
devices::Graphics::Instance()->Resize(width, height);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_DISPLAYCHANGE:
|
case WM_DISPLAYCHANGE:
|
||||||
{
|
{
|
||||||
|
E2D_LOG("The display resolution has changed");
|
||||||
::InvalidateRect(hwnd, nullptr, FALSE);
|
::InvalidateRect(hwnd, nullptr, FALSE);
|
||||||
}
|
}
|
||||||
result = 0;
|
|
||||||
was_handled = true;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
{
|
{
|
||||||
if (game->OnClose())
|
E2D_LOG("Received a message to close the window");
|
||||||
|
|
||||||
|
SysEvent event(SysEvent::WindowClose);
|
||||||
|
Dispatch(&event);
|
||||||
|
|
||||||
|
if (OnClose())
|
||||||
{
|
{
|
||||||
::DestroyWindow(hwnd);
|
::DestroyWindow(hwnd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result = 0;
|
|
||||||
was_handled = true;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
{
|
{
|
||||||
game->OnExit();
|
E2D_LOG("Window was destroyed");
|
||||||
|
|
||||||
|
OnExit();
|
||||||
::PostQuitMessage(0);
|
::PostQuitMessage(0);
|
||||||
}
|
}
|
||||||
result = 1;
|
|
||||||
was_handled = true;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WM_SIZE:
|
||||||
|
{
|
||||||
|
if (SIZE_MAXHIDE == wparam || SIZE_MINIMIZED == wparam)
|
||||||
|
{
|
||||||
|
active_ = false;
|
||||||
|
|
||||||
|
E2D_LOG("Window minimized");
|
||||||
|
}
|
||||||
|
else if (SIZE_RESTORED == wparam)
|
||||||
|
{
|
||||||
|
active_ = true;
|
||||||
|
::InvalidateRect(hwnd, nullptr, FALSE);
|
||||||
|
|
||||||
|
E2D_LOG("Window restored");
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT width = LOWORD(lparam);
|
||||||
|
UINT height = HIWORD(lparam);
|
||||||
|
|
||||||
|
// 如果程序接收到一个 WM_SIZE 消息,这个方法将调整渲染
|
||||||
|
// 目标的大小。它可能会调用失败,但是这里可以忽略有可能的
|
||||||
|
// 错误,因为这个错误将在下一次调用 EndDraw 时产生
|
||||||
|
Graphics::Instance()->Resize(width, height);
|
||||||
|
}
|
||||||
|
unhandled = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_ACTIVATE:
|
||||||
|
{
|
||||||
|
if (WA_INACTIVE == wparam)
|
||||||
|
{
|
||||||
|
E2D_LOG("Window deactivated");
|
||||||
|
|
||||||
|
SysEvent event(SysEvent::WindowDeavtivate);
|
||||||
|
Dispatch(&event);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
E2D_LOG("Window activated");
|
||||||
|
|
||||||
|
SysEvent event(SysEvent::WindowActivate);
|
||||||
|
Dispatch(&event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unhandled = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_SETTEXT:
|
||||||
|
{
|
||||||
|
E2D_LOG("Window title changed");
|
||||||
|
}
|
||||||
|
unhandled = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_SETICON:
|
||||||
|
{
|
||||||
|
E2D_LOG("Window icon changed");
|
||||||
|
}
|
||||||
|
unhandled = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
unhandled = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return !unhandled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Game::Dispatch(Event * event)
|
||||||
|
{
|
||||||
|
if (transition_)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (curr_scene_)
|
||||||
|
curr_scene_->DispatchEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT CALLBACK Game::WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||||
|
{
|
||||||
|
LRESULT result = 0;
|
||||||
|
bool was_handled = false;
|
||||||
|
|
||||||
|
Game * game = reinterpret_cast<Game*>(
|
||||||
|
static_cast<LONG_PTR>(::GetWindowLongW(hwnd, GWLP_USERDATA))
|
||||||
|
);
|
||||||
|
|
||||||
|
if (game)
|
||||||
|
{
|
||||||
|
was_handled = game->HandleMessage(hwnd, msg, wparam, lparam);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!was_handled)
|
if (!was_handled)
|
||||||
{
|
{
|
||||||
result = ::DefWindowProcW(hwnd, msg, w_param, l_param);
|
result = ::DefWindowProcW(hwnd, msg, wparam, lparam);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,7 @@
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
#include "KeyEvent.h"
|
#include "Event.hpp"
|
||||||
#include "MouseEvent.h"
|
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
|
|
@ -62,11 +61,10 @@ namespace easy2d
|
||||||
|
|
||||||
virtual ~Game();
|
virtual ~Game();
|
||||||
|
|
||||||
// 退出时
|
// 退出游戏
|
||||||
virtual void OnExit() {}
|
virtual void OnExit() {}
|
||||||
|
|
||||||
// 窗口关闭时
|
// 窗口关闭
|
||||||
// 返回值:返回 false 将阻止窗口关闭
|
|
||||||
virtual bool OnClose() { return true; }
|
virtual bool OnClose() { return true; }
|
||||||
|
|
||||||
// 初始化
|
// 初始化
|
||||||
|
|
@ -81,12 +79,12 @@ namespace easy2d
|
||||||
void Quit();
|
void Quit();
|
||||||
|
|
||||||
// 切换场景
|
// 切换场景
|
||||||
bool EnterScene(
|
void EnterScene(
|
||||||
spScene const& scene /* 场景 */
|
spScene const& scene /* 场景 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 切换场景
|
// 切换场景
|
||||||
bool EnterScene(
|
void EnterScene(
|
||||||
spScene const& scene, /* 场景 */
|
spScene const& scene, /* 场景 */
|
||||||
spTransition const& transition /* 场景动画 */
|
spTransition const& transition /* 场景动画 */
|
||||||
);
|
);
|
||||||
|
|
@ -98,32 +96,29 @@ namespace easy2d
|
||||||
void SetTimeScale(float scale);
|
void SetTimeScale(float scale);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Render();
|
void Render(HWND);
|
||||||
|
|
||||||
void Update();
|
void Update();
|
||||||
|
|
||||||
void Dispatch(
|
bool HandleMessage(
|
||||||
MouseEvent const& e
|
HWND hwnd,
|
||||||
|
UINT msg,
|
||||||
|
WPARAM wparam,
|
||||||
|
LPARAM lparam
|
||||||
);
|
);
|
||||||
|
|
||||||
void Dispatch(
|
void Dispatch(
|
||||||
KeyEvent const& e
|
Event* event
|
||||||
);
|
);
|
||||||
|
|
||||||
static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool initialized_;
|
bool debug_;
|
||||||
bool debug_enabled_;
|
bool active_;
|
||||||
bool window_inactived_;
|
|
||||||
float time_scale_;
|
float time_scale_;
|
||||||
spScene curr_scene_;
|
spScene curr_scene_;
|
||||||
spScene next_scene_;
|
spScene next_scene_;
|
||||||
spTransition transition_;
|
spTransition transition_;
|
||||||
|
|
||||||
WindowImpl* window_;
|
|
||||||
devices::GraphicsDevice* graphics_;
|
|
||||||
devices::InputDevice* input_;
|
|
||||||
devices::AudioDevice* audio_;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ namespace easy2d
|
||||||
{
|
{
|
||||||
if (geometry_ && geometry_->geo_)
|
if (geometry_ && geometry_->geo_)
|
||||||
{
|
{
|
||||||
auto graphics = devices::Graphics::Instance();
|
auto graphics = Graphics::Instance();
|
||||||
graphics->SetTransform(geometry_->GetTransformMatrix() * GetTransformMatrix());
|
graphics->SetTransform(geometry_->GetTransformMatrix() * GetTransformMatrix());
|
||||||
|
|
||||||
graphics->FillGeometry(
|
graphics->FillGeometry(
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ namespace easy2d
|
||||||
bool Image::Load(Resource const& res)
|
bool Image::Load(Resource const& res)
|
||||||
{
|
{
|
||||||
cpBitmap bitmap;
|
cpBitmap bitmap;
|
||||||
HRESULT hr = devices::Graphics::Instance()->CreateBitmapFromResource(bitmap, res);
|
HRESULT hr = Graphics::Instance()->CreateBitmapFromResource(bitmap, res);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
logs::Errorln(hr, "Load Image from resource failed!");
|
logs::Errorln(hr, "Load Image from resource failed!");
|
||||||
|
|
@ -94,7 +94,7 @@ namespace easy2d
|
||||||
String image_file_path = image_file.GetPath();
|
String image_file_path = image_file.GetPath();
|
||||||
|
|
||||||
cpBitmap bitmap;
|
cpBitmap bitmap;
|
||||||
HRESULT hr = devices::Graphics::Instance()->CreateBitmapFromFile(bitmap, image_file_path);
|
HRESULT hr = Graphics::Instance()->CreateBitmapFromFile(bitmap, image_file_path);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
logs::Errorln(hr, "Load Image from file failed!");
|
logs::Errorln(hr, "Load Image from file failed!");
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,6 @@
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
namespace devices
|
|
||||||
{
|
|
||||||
InputDevice::InputDevice()
|
InputDevice::InputDevice()
|
||||||
: hwnd_(nullptr)
|
: hwnd_(nullptr)
|
||||||
, scale_x_(1.f)
|
, scale_x_(1.f)
|
||||||
|
|
@ -55,57 +53,63 @@ namespace easy2d
|
||||||
{
|
{
|
||||||
memcpy(keys_cache_, keys_, sizeof(keys_cache_));
|
memcpy(keys_cache_, keys_, sizeof(keys_cache_));
|
||||||
GetKeyboardState(keys_);
|
GetKeyboardState(keys_);
|
||||||
|
|
||||||
POINT client_cursor_pos;
|
|
||||||
GetCursorPos(&client_cursor_pos);
|
|
||||||
ScreenToClient(hwnd_, &client_cursor_pos);
|
|
||||||
|
|
||||||
mouse_pos_ = Point(client_cursor_pos.x * scale_x_, client_cursor_pos.y * scale_y_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InputDevice::IsDown(KeyCode code)
|
bool InputDevice::IsDown(KeyCode code)
|
||||||
{
|
{
|
||||||
if (keys_[static_cast<int>(code)] & 0x80)
|
return !!(keys_[static_cast<int>(code)] & 0x80);
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InputDevice::IsDown(MouseCode code)
|
bool InputDevice::IsDown(MouseButton btn)
|
||||||
{
|
{
|
||||||
if (keys_[static_cast<int>(code)] & 0x80)
|
return !!(keys_[static_cast<int>(btn)] & 0x80);
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InputDevice::WasPressed(KeyCode code)
|
bool InputDevice::WasPressed(KeyCode code)
|
||||||
{
|
{
|
||||||
if (keys_cache_[static_cast<int>(code)] & 0x80 &&
|
return !(keys_cache_[static_cast<int>(code)] & 0x80)
|
||||||
!(keys_[static_cast<int>(code)] & 0x80))
|
&& (keys_[static_cast<int>(code)] & 0x80);
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InputDevice::WasPressed(MouseCode code)
|
bool InputDevice::WasPressed(MouseButton btn)
|
||||||
{
|
{
|
||||||
if (keys_cache_[static_cast<int>(code)] & 0x80 &&
|
return !(keys_cache_[static_cast<int>(btn)] & 0x80)
|
||||||
!(keys_[static_cast<int>(code)] & 0x80))
|
&& (keys_[static_cast<int>(btn)] & 0x80);
|
||||||
return true;
|
}
|
||||||
return false;
|
|
||||||
|
bool InputDevice::WasReleased(KeyCode code)
|
||||||
|
{
|
||||||
|
return (keys_cache_[static_cast<int>(code)] & 0x80)
|
||||||
|
&& !(keys_[static_cast<int>(code)] & 0x80);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InputDevice::WasReleased(MouseButton btn)
|
||||||
|
{
|
||||||
|
return (keys_cache_[static_cast<int>(btn)] & 0x80)
|
||||||
|
&& !(keys_[static_cast<int>(btn)] & 0x80);
|
||||||
}
|
}
|
||||||
|
|
||||||
float InputDevice::GetMouseX()
|
float InputDevice::GetMouseX()
|
||||||
{
|
{
|
||||||
return mouse_pos_.x;
|
POINT pos;
|
||||||
|
::GetCursorPos(&pos);
|
||||||
|
::ScreenToClient(hwnd_, &pos);
|
||||||
|
return pos.x * scale_x_;
|
||||||
}
|
}
|
||||||
|
|
||||||
float InputDevice::GetMouseY()
|
float InputDevice::GetMouseY()
|
||||||
{
|
{
|
||||||
return mouse_pos_.y;
|
POINT pos;
|
||||||
|
::GetCursorPos(&pos);
|
||||||
|
::ScreenToClient(hwnd_, &pos);
|
||||||
|
return pos.y * scale_y_;
|
||||||
}
|
}
|
||||||
|
|
||||||
Point InputDevice::GetMousePos()
|
Point InputDevice::GetMousePos()
|
||||||
{
|
{
|
||||||
return mouse_pos_;
|
POINT pos;
|
||||||
}
|
::GetCursorPos(&pos);
|
||||||
|
::ScreenToClient(hwnd_, &pos);
|
||||||
|
return Point{ pos.x * scale_x_, pos.y * scale_y_ };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -24,8 +24,6 @@
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
namespace devices
|
|
||||||
{
|
|
||||||
class InputDevice
|
class InputDevice
|
||||||
: protected Noncopyable
|
: protected Noncopyable
|
||||||
{
|
{
|
||||||
|
|
@ -34,33 +32,43 @@ namespace easy2d
|
||||||
public:
|
public:
|
||||||
HRESULT Init(HWND hwnd, float scale_x, float scale_y, bool debug);
|
HRESULT Init(HWND hwnd, float scale_x, float scale_y, bool debug);
|
||||||
|
|
||||||
// 检测键盘某按键是否正被按下
|
// 检测键盘按键是否正被按下
|
||||||
bool IsDown(
|
bool IsDown(
|
||||||
KeyCode code
|
KeyCode code
|
||||||
);
|
);
|
||||||
|
|
||||||
// 检测鼠标按键是否正被按下
|
// 检测鼠标按键是否正被按下
|
||||||
bool IsDown(
|
bool IsDown(
|
||||||
MouseCode code
|
MouseButton btn
|
||||||
);
|
);
|
||||||
|
|
||||||
// 检测键盘某按键是否点击
|
// 检测键盘按键是否刚被点击
|
||||||
bool WasPressed(
|
bool WasPressed(
|
||||||
KeyCode code
|
KeyCode code
|
||||||
);
|
);
|
||||||
|
|
||||||
// 检测鼠标按键是否点击
|
// 检测鼠标按键是否刚被点击
|
||||||
bool WasPressed(
|
bool WasPressed(
|
||||||
MouseCode code
|
MouseButton btn
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获得鼠标X轴坐标值
|
// 检测键盘按键是否刚抬起
|
||||||
|
bool WasReleased(
|
||||||
|
KeyCode code
|
||||||
|
);
|
||||||
|
|
||||||
|
// 检测鼠标按键是否刚抬起
|
||||||
|
bool WasReleased(
|
||||||
|
MouseButton btn
|
||||||
|
);
|
||||||
|
|
||||||
|
// 获得鼠标 x 坐标
|
||||||
float GetMouseX();
|
float GetMouseX();
|
||||||
|
|
||||||
// 获得鼠标Y轴坐标值
|
// 获得鼠标 y 坐标
|
||||||
float GetMouseY();
|
float GetMouseY();
|
||||||
|
|
||||||
// 获得鼠标坐标值
|
// 获得鼠标坐标
|
||||||
Point GetMousePos();
|
Point GetMousePos();
|
||||||
|
|
||||||
void Update();
|
void Update();
|
||||||
|
|
@ -76,9 +84,7 @@ namespace easy2d
|
||||||
float scale_y_;
|
float scale_y_;
|
||||||
BYTE keys_[256];
|
BYTE keys_[256];
|
||||||
BYTE keys_cache_[256];
|
BYTE keys_cache_[256];
|
||||||
Point mouse_pos_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
E2D_DECLARE_SINGLETON_TYPE(InputDevice, Input);
|
E2D_DECLARE_SINGLETON_TYPE(InputDevice, Input);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,29 +18,30 @@
|
||||||
// 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 "KeyEvent.h"
|
#pragma once
|
||||||
|
#include "Event.hpp"
|
||||||
|
#include "BaseTypes.hpp"
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
KeyEvent::KeyEvent(UINT message, WPARAM w_param, LPARAM l_param)
|
class KeyEvent
|
||||||
: message_(message)
|
: public Event
|
||||||
, w_param_(w_param)
|
|
||||||
, l_param_(l_param)
|
|
||||||
{
|
{
|
||||||
}
|
public:
|
||||||
|
enum Type
|
||||||
|
{
|
||||||
|
First = WM_KEYFIRST,
|
||||||
|
|
||||||
KeyCode KeyEvent::GetCode() const
|
Down, // 键按下
|
||||||
{
|
Up, // 键抬起
|
||||||
return static_cast<KeyCode>(w_param_);
|
|
||||||
}
|
|
||||||
|
|
||||||
int KeyEvent::GetCount() const
|
Last // 结束标志
|
||||||
{
|
};
|
||||||
return static_cast<int>((DWORD)l_param_ & 0x0000FFFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
KeyEvent::Type KeyEvent::GetType() const
|
KeyEvent(EventType type, KeyCode key) : Event(type), key(key) {}
|
||||||
{
|
|
||||||
return Type(message_);
|
static bool Check(Event* e) { return e->type > Type::First && e->type < Type::Last; }
|
||||||
}
|
|
||||||
|
KeyCode key;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -1,85 +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 "MouseEvent.h"
|
|
||||||
#include "window.h"
|
|
||||||
|
|
||||||
namespace easy2d
|
|
||||||
{
|
|
||||||
MouseEvent::MouseEvent(UINT message, WPARAM w_param, LPARAM l_param)
|
|
||||||
: message_(message)
|
|
||||||
, w_param_(w_param)
|
|
||||||
, l_param_(l_param)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
float MouseEvent::GetX() const
|
|
||||||
{
|
|
||||||
return ((float)(short)LOWORD(l_param_)) * Window::Instance()->GetContentScaleX();
|
|
||||||
}
|
|
||||||
|
|
||||||
float MouseEvent::GetY() const
|
|
||||||
{
|
|
||||||
return ((float)(short)HIWORD(l_param_)) * Window::Instance()->GetContentScaleY();
|
|
||||||
}
|
|
||||||
|
|
||||||
Point MouseEvent::GetPosition() const
|
|
||||||
{
|
|
||||||
return Point(
|
|
||||||
((float)(short)LOWORD(l_param_)) * Window::Instance()->GetContentScaleX(),
|
|
||||||
((float)(short)HIWORD(l_param_)) * Window::Instance()->GetContentScaleY()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MouseEvent::IsShiftDown() const
|
|
||||||
{
|
|
||||||
return GET_KEYSTATE_WPARAM(w_param_) == MK_SHIFT;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MouseEvent::IsCtrlDown() const
|
|
||||||
{
|
|
||||||
return GET_KEYSTATE_WPARAM(w_param_) == MK_CONTROL;
|
|
||||||
}
|
|
||||||
|
|
||||||
float MouseEvent::GetWheelDelta() const
|
|
||||||
{
|
|
||||||
return static_cast<float>(GET_WHEEL_DELTA_WPARAM(w_param_));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MouseEvent::IsLButtonDown() const
|
|
||||||
{
|
|
||||||
return GET_KEYSTATE_WPARAM(w_param_) == MK_LBUTTON;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MouseEvent::IsRButtonDown() const
|
|
||||||
{
|
|
||||||
return GET_KEYSTATE_WPARAM(w_param_) == MK_RBUTTON;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MouseEvent::IsMButtonDown() const
|
|
||||||
{
|
|
||||||
return GET_KEYSTATE_WPARAM(w_param_) == MK_MBUTTON;
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseEvent::Type MouseEvent::GetType() const
|
|
||||||
{
|
|
||||||
return Type(message_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,97 +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.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "macros.h"
|
|
||||||
#include "BaseTypes.hpp"
|
|
||||||
|
|
||||||
namespace easy2d
|
|
||||||
{
|
|
||||||
// 鼠标消息
|
|
||||||
class MouseEvent
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// 鼠标消息类型
|
|
||||||
enum class Type : int
|
|
||||||
{
|
|
||||||
Move = 0x0200, // 鼠标移动
|
|
||||||
LeftDown, // 鼠标左键按下
|
|
||||||
LeftUp, // 鼠标左键抬起
|
|
||||||
LeftDoubleClick, // 鼠标左键双击
|
|
||||||
RightDown, // 鼠标右键按下
|
|
||||||
RightUp, // 鼠标右键抬起
|
|
||||||
RightDoubleClick, // 鼠标右键双击
|
|
||||||
MiddleDown, // 鼠标中键按下
|
|
||||||
MiddleUp, // 鼠标中键抬起
|
|
||||||
MiddleDoubleClick, // 鼠标中键双击
|
|
||||||
Wheel // 滑动滚轮
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit MouseEvent(
|
|
||||||
UINT message,
|
|
||||||
WPARAM w_param,
|
|
||||||
LPARAM l_param
|
|
||||||
);
|
|
||||||
|
|
||||||
// 获取鼠标横坐标
|
|
||||||
float GetX() const;
|
|
||||||
|
|
||||||
// 获取鼠标纵坐标
|
|
||||||
float GetY() const;
|
|
||||||
|
|
||||||
// 获取鼠标坐标
|
|
||||||
Point GetPosition() const;
|
|
||||||
|
|
||||||
// 获取事件类型
|
|
||||||
MouseEvent::Type GetType() const;
|
|
||||||
|
|
||||||
float GetWheelDelta() const;
|
|
||||||
|
|
||||||
// 鼠标左键是否按下
|
|
||||||
bool IsLButtonDown() const;
|
|
||||||
|
|
||||||
// 鼠标右键是否按下
|
|
||||||
bool IsRButtonDown() const;
|
|
||||||
|
|
||||||
// 鼠标中键是否按下
|
|
||||||
bool IsMButtonDown() const;
|
|
||||||
|
|
||||||
// Shift 键是否按下
|
|
||||||
bool IsShiftDown() const;
|
|
||||||
|
|
||||||
// Ctrl 键是否按下
|
|
||||||
bool IsCtrlDown() const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
UINT message_;
|
|
||||||
WPARAM w_param_;
|
|
||||||
LPARAM l_param_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// 鼠标消息处理接口
|
|
||||||
class MouseEventHandler
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// 处理鼠标消息
|
|
||||||
virtual void Handle(MouseEvent e) = 0;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "Event.hpp"
|
||||||
|
|
||||||
|
namespace easy2d
|
||||||
|
{
|
||||||
|
class MouseEvent
|
||||||
|
: public Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum Type
|
||||||
|
{
|
||||||
|
First = WM_MOUSEFIRST,
|
||||||
|
|
||||||
|
Move, // 移动
|
||||||
|
Down, // 按下
|
||||||
|
Up, // 抬起
|
||||||
|
Wheel, // 滚轮滚动
|
||||||
|
|
||||||
|
Last // 结束标志
|
||||||
|
};
|
||||||
|
|
||||||
|
MouseEvent(EventType type, float x, float y, float wheel_delta) : Event(type), x(x), y(y), wheel_delta(wheel_delta), button_down(false) {}
|
||||||
|
|
||||||
|
static bool Check(Event* e) { return e->type > Type::First && e->type < Type::Last; }
|
||||||
|
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
float wheel_delta;
|
||||||
|
bool button_down;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -87,7 +87,7 @@ namespace easy2d
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = devices::Audio::Instance()->CreateVoice(voice_, transcoder.GetWaveFormatEx());
|
hr = Audio::Instance()->CreateVoice(voice_, transcoder.GetWaveFormatEx());
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
if (wave_data_)
|
if (wave_data_)
|
||||||
|
|
@ -119,7 +119,7 @@ namespace easy2d
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = devices::Audio::Instance()->CreateVoice(voice_, transcoder.GetWaveFormatEx());
|
hr = Audio::Instance()->CreateVoice(voice_, transcoder.GetWaveFormatEx());
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
if (wave_data_)
|
if (wave_data_)
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ namespace easy2d
|
||||||
|
|
||||||
UpdateTransform();
|
UpdateTransform();
|
||||||
|
|
||||||
auto graphics = devices::Graphics::Instance();
|
auto graphics = Graphics::Instance();
|
||||||
|
|
||||||
if (children_.IsEmpty())
|
if (children_.IsEmpty())
|
||||||
{
|
{
|
||||||
|
|
@ -146,13 +146,36 @@ namespace easy2d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Node::DispatchEvent(Event * e)
|
||||||
|
{
|
||||||
|
if (!visible_)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this->HandleEvent(e);
|
||||||
|
|
||||||
|
if (!e->has_target)
|
||||||
|
{
|
||||||
|
EventDispatcher::DispatchEvent(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Node::HandleEvent(Event * e)
|
||||||
|
{
|
||||||
|
spNode prev;
|
||||||
|
for (auto child = children_.Last(); child; child = prev)
|
||||||
|
{
|
||||||
|
prev = child->PrevItem();
|
||||||
|
child->HandleEvent(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Node::DrawBorder()
|
void Node::DrawBorder()
|
||||||
{
|
{
|
||||||
if (visible_)
|
if (visible_)
|
||||||
{
|
{
|
||||||
if (border_)
|
if (border_)
|
||||||
{
|
{
|
||||||
devices::Graphics::Instance()->DrawGeometry(border_, border_color_, 1.5f);
|
Graphics::Instance()->DrawGeometry(border_, border_color_, 1.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto child = children_.First(); child; child = child->NextItem())
|
for (auto child = children_.First(); child; child = child->NextItem())
|
||||||
|
|
@ -180,6 +203,16 @@ namespace easy2d
|
||||||
return final_matrix_;
|
return final_matrix_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spNode Node::GetParent() const
|
||||||
|
{
|
||||||
|
return parent_;
|
||||||
|
}
|
||||||
|
|
||||||
|
spScene Node::GetScene() const
|
||||||
|
{
|
||||||
|
return scene_;
|
||||||
|
}
|
||||||
|
|
||||||
void Node::UpdateTransform()
|
void Node::UpdateTransform()
|
||||||
{
|
{
|
||||||
if (!dirty_transform_)
|
if (!dirty_transform_)
|
||||||
|
|
@ -241,44 +274,6 @@ namespace easy2d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Node::Dispatch(const MouseEvent & e, bool handled)
|
|
||||||
{
|
|
||||||
if (visible_)
|
|
||||||
{
|
|
||||||
spNode prev;
|
|
||||||
for (auto child = children_.Last(); child; child = prev)
|
|
||||||
{
|
|
||||||
prev = child->PrevItem();
|
|
||||||
handled = child->Dispatch(e, handled);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto handler = dynamic_cast<MouseEventHandler*>(this);
|
|
||||||
if (handler)
|
|
||||||
handler->Handle(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return handled;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Node::Dispatch(const KeyEvent & e, bool handled)
|
|
||||||
{
|
|
||||||
if (visible_)
|
|
||||||
{
|
|
||||||
spNode prev;
|
|
||||||
for (auto child = children_.Last(); child; child = prev)
|
|
||||||
{
|
|
||||||
prev = child->PrevItem();
|
|
||||||
handled = child->Dispatch(e, handled);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto handler = dynamic_cast<KeyEventHandler*>(this);
|
|
||||||
if (handler)
|
|
||||||
handler->Handle(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return handled;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Node::UpdateOpacity()
|
void Node::UpdateOpacity()
|
||||||
{
|
{
|
||||||
if (parent_)
|
if (parent_)
|
||||||
|
|
@ -291,6 +286,15 @@ namespace easy2d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Node::SetScene(Scene * scene)
|
||||||
|
{
|
||||||
|
scene_ = scene;
|
||||||
|
for (auto child = children_.First(); child; child = child->NextItem())
|
||||||
|
{
|
||||||
|
child->scene_ = scene;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Node::SetZOrder(int order)
|
void Node::SetZOrder(int order)
|
||||||
{
|
{
|
||||||
if (z_order_ == order)
|
if (z_order_ == order)
|
||||||
|
|
@ -402,6 +406,7 @@ namespace easy2d
|
||||||
|
|
||||||
children_.PushBack(Node::ItemType(child));
|
children_.PushBack(Node::ItemType(child));
|
||||||
child->parent_ = this;
|
child->parent_ = this;
|
||||||
|
child->SetScene(this->scene_);
|
||||||
child->dirty_transform_ = true;
|
child->dirty_transform_ = true;
|
||||||
child->SetZOrder(z_order);
|
child->SetZOrder(z_order);
|
||||||
child->UpdateOpacity();
|
child->UpdateOpacity();
|
||||||
|
|
@ -471,12 +476,12 @@ namespace easy2d
|
||||||
logs::Warningln("Node::RemoveChild failed, child is nullptr");
|
logs::Warningln("Node::RemoveChild failed, child is nullptr");
|
||||||
|
|
||||||
if (children_.IsEmpty())
|
if (children_.IsEmpty())
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (child)
|
if (child)
|
||||||
{
|
{
|
||||||
|
child->parent_ = nullptr;
|
||||||
|
if (child->scene_) child->SetScene(nullptr);
|
||||||
children_.Remove(Node::ItemType(child));
|
children_.Remove(Node::ItemType(child));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -497,7 +502,9 @@ namespace easy2d
|
||||||
next = child->NextItem();
|
next = child->NextItem();
|
||||||
|
|
||||||
if (child->hash_name_ == hash_code && child->name_ == child_name)
|
if (child->hash_name_ == hash_code && child->name_ == child_name)
|
||||||
children_.Remove(child);
|
{
|
||||||
|
RemoveChild(child);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,9 @@
|
||||||
#include "base.hpp"
|
#include "base.hpp"
|
||||||
#include "time.h"
|
#include "time.h"
|
||||||
#include "Unit.h"
|
#include "Unit.h"
|
||||||
#include "KeyEvent.h"
|
|
||||||
#include "MouseEvent.h"
|
|
||||||
#include "ActionManager.h"
|
|
||||||
#include "TaskManager.h"
|
#include "TaskManager.h"
|
||||||
|
#include "ActionManager.h"
|
||||||
|
#include "EventDispatcher.h"
|
||||||
#include "intrusive/List.hpp"
|
#include "intrusive/List.hpp"
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
|
|
@ -35,8 +34,9 @@ namespace easy2d
|
||||||
// 节点
|
// 节点
|
||||||
class Node
|
class Node
|
||||||
: public Unit
|
: public Unit
|
||||||
, public ActionManager
|
|
||||||
, public TaskManager
|
, public TaskManager
|
||||||
|
, public ActionManager
|
||||||
|
, public EventDispatcher
|
||||||
, protected intrusive::ListItem<spNode>
|
, protected intrusive::ListItem<spNode>
|
||||||
{
|
{
|
||||||
friend class Game;
|
friend class Game;
|
||||||
|
|
@ -59,6 +59,9 @@ namespace easy2d
|
||||||
// 渲染节点
|
// 渲染节点
|
||||||
virtual void OnRender();
|
virtual void OnRender();
|
||||||
|
|
||||||
|
// 处理事件
|
||||||
|
virtual void HandleEvent(Event* e);
|
||||||
|
|
||||||
// 获取显示状态
|
// 获取显示状态
|
||||||
bool IsVisible() const { return visible_; }
|
bool IsVisible() const { return visible_; }
|
||||||
|
|
||||||
|
|
@ -96,7 +99,10 @@ namespace easy2d
|
||||||
virtual math::Matrix const& GetTransformMatrix() override;
|
virtual math::Matrix const& GetTransformMatrix() override;
|
||||||
|
|
||||||
// 获取父节点
|
// 获取父节点
|
||||||
virtual spNode GetParent() const { return parent_; }
|
spNode GetParent() const;
|
||||||
|
|
||||||
|
// 获取所在场景
|
||||||
|
spScene GetScene() const;
|
||||||
|
|
||||||
// 设置是否显示
|
// 设置是否显示
|
||||||
void SetVisible(
|
void SetVisible(
|
||||||
|
|
@ -215,6 +221,8 @@ namespace easy2d
|
||||||
// 从父节点移除
|
// 从父节点移除
|
||||||
void RemoveFromParent();
|
void RemoveFromParent();
|
||||||
|
|
||||||
|
virtual void DispatchEvent(Event* e) override;
|
||||||
|
|
||||||
// 设置默认支点
|
// 设置默认支点
|
||||||
static void SetDefaultPivot(
|
static void SetDefaultPivot(
|
||||||
float pivot_x,
|
float pivot_x,
|
||||||
|
|
@ -240,15 +248,7 @@ namespace easy2d
|
||||||
|
|
||||||
void UpdateOpacity();
|
void UpdateOpacity();
|
||||||
|
|
||||||
virtual bool Dispatch(
|
void SetScene(Scene* scene);
|
||||||
const MouseEvent& e,
|
|
||||||
bool handled
|
|
||||||
);
|
|
||||||
|
|
||||||
virtual bool Dispatch(
|
|
||||||
const KeyEvent& e,
|
|
||||||
bool handled
|
|
||||||
);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool inited_;
|
bool inited_;
|
||||||
|
|
@ -260,6 +260,7 @@ namespace easy2d
|
||||||
String name_;
|
String name_;
|
||||||
size_t hash_name_;
|
size_t hash_name_;
|
||||||
Node* parent_;
|
Node* parent_;
|
||||||
|
Scene* scene_;
|
||||||
Color border_color_;
|
Color border_color_;
|
||||||
Children children_;
|
Children children_;
|
||||||
cpGeometry border_;
|
cpGeometry border_;
|
||||||
|
|
|
||||||
|
|
@ -20,14 +20,38 @@
|
||||||
|
|
||||||
#include "Scene.h"
|
#include "Scene.h"
|
||||||
#include "Node.h"
|
#include "Node.h"
|
||||||
|
#include "logs.h"
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
Scene::Scene()
|
Scene::Scene()
|
||||||
{
|
{
|
||||||
|
AddListener(SysEvent::WindowActivate, std::bind(&Scene::OnActivate, this));
|
||||||
|
AddListener(SysEvent::WindowDeavtivate, std::bind(&Scene::OnDeactivate, this));
|
||||||
|
|
||||||
|
scene_ = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Scene::~Scene()
|
Scene::~Scene()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Scene::OnEnter()
|
||||||
|
{
|
||||||
|
E2D_LOG("Scene entered");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scene::OnExit()
|
||||||
|
{
|
||||||
|
E2D_LOG("Scene exited");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scene::OnDeactivate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scene::OnActivate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,15 @@ namespace easy2d
|
||||||
virtual ~Scene();
|
virtual ~Scene();
|
||||||
|
|
||||||
// 进入场景
|
// 进入场景
|
||||||
virtual void OnEnter() {}
|
virtual void OnEnter();
|
||||||
|
|
||||||
// 退出场景
|
// 退出场景
|
||||||
virtual void OnExit() {}
|
virtual void OnExit();
|
||||||
|
|
||||||
|
// 窗口获得焦点
|
||||||
|
virtual void OnActivate();
|
||||||
|
|
||||||
|
// 窗口失去焦点
|
||||||
|
virtual void OnDeactivate();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ namespace easy2d
|
||||||
{
|
{
|
||||||
if (image_)
|
if (image_)
|
||||||
{
|
{
|
||||||
devices::Graphics::Instance()->DrawImage(image_);
|
Graphics::Instance()->DrawImage(image_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -43,7 +43,7 @@ namespace easy2d
|
||||||
void TaskManager::AddTask(spTask const& task)
|
void TaskManager::AddTask(spTask const& task)
|
||||||
{
|
{
|
||||||
if (!task)
|
if (!task)
|
||||||
logs::Warningln("Node::AddTask failed, action is nullptr");
|
logs::Warningln("AddTask failed, task is nullptr");
|
||||||
|
|
||||||
if (task)
|
if (task)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -295,7 +295,7 @@ namespace easy2d
|
||||||
{
|
{
|
||||||
if (text_layout_)
|
if (text_layout_)
|
||||||
{
|
{
|
||||||
auto graphics = devices::Graphics::Instance();
|
auto graphics = Graphics::Instance();
|
||||||
graphics->SetTextStyle(
|
graphics->SetTextStyle(
|
||||||
style_.color,
|
style_.color,
|
||||||
style_.outline,
|
style_.outline,
|
||||||
|
|
|
||||||
|
|
@ -66,14 +66,14 @@ namespace easy2d
|
||||||
if (in_scene_)
|
if (in_scene_)
|
||||||
{
|
{
|
||||||
ThrowIfFailed(
|
ThrowIfFailed(
|
||||||
devices::Graphics::Instance()->CreateLayer(in_layer_)
|
Graphics::Instance()->CreateLayer(in_layer_)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (out_scene_)
|
if (out_scene_)
|
||||||
{
|
{
|
||||||
ThrowIfFailed(
|
ThrowIfFailed(
|
||||||
devices::Graphics::Instance()->CreateLayer(out_layer_)
|
Graphics::Instance()->CreateLayer(out_layer_)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -101,7 +101,7 @@ namespace easy2d
|
||||||
|
|
||||||
void Transition::Render()
|
void Transition::Render()
|
||||||
{
|
{
|
||||||
auto graphics = devices::Graphics::Instance();
|
auto graphics = Graphics::Instance();
|
||||||
|
|
||||||
if (out_scene_)
|
if (out_scene_)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ namespace easy2d
|
||||||
{
|
{
|
||||||
Destroy();
|
Destroy();
|
||||||
|
|
||||||
devices::Audio::Instance()->DeleteVoice(this);
|
Audio::Instance()->DeleteVoice(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT Voice::Play(const BYTE * wave_data, UINT32 data_size, UINT32 loop_count)
|
HRESULT Voice::Play(const BYTE * wave_data, UINT32 data_size, UINT32 loop_count)
|
||||||
|
|
@ -155,8 +155,6 @@ namespace easy2d
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace devices
|
|
||||||
{
|
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
// AudioDevice
|
// AudioDevice
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
@ -240,5 +238,5 @@ namespace easy2d
|
||||||
{
|
{
|
||||||
x_audio2_->StopEngine();
|
x_audio2_->StopEngine();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -72,8 +72,7 @@ namespace easy2d
|
||||||
IXAudio2SourceVoice* source_voice_;
|
IXAudio2SourceVoice* source_voice_;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace devices
|
|
||||||
{
|
|
||||||
class AudioDevice
|
class AudioDevice
|
||||||
: protected Noncopyable
|
: protected Noncopyable
|
||||||
{
|
{
|
||||||
|
|
@ -111,5 +110,4 @@ namespace easy2d
|
||||||
};
|
};
|
||||||
|
|
||||||
E2D_DECLARE_SINGLETON_TYPE(AudioDevice, Audio);
|
E2D_DECLARE_SINGLETON_TYPE(AudioDevice, Audio);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
#include "ObjectBase.h"
|
#include "ObjectBase.h"
|
||||||
#include "intrusive/SmartPointer.hpp"
|
#include "intrusive/SmartPointer.hpp"
|
||||||
#include "d2dres.hpp"
|
#include "d2dres.hpp"
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#ifndef E2D_DECLARE_SMART_PTR
|
#ifndef E2D_DECLARE_SMART_PTR
|
||||||
#define E2D_DECLARE_SMART_PTR(class_name)\
|
#define E2D_DECLARE_SMART_PTR(class_name)\
|
||||||
|
|
@ -43,6 +44,7 @@ namespace easy2d
|
||||||
E2D_DECLARE_SMART_PTR(Image);
|
E2D_DECLARE_SMART_PTR(Image);
|
||||||
E2D_DECLARE_SMART_PTR(Music);
|
E2D_DECLARE_SMART_PTR(Music);
|
||||||
E2D_DECLARE_SMART_PTR(Task);
|
E2D_DECLARE_SMART_PTR(Task);
|
||||||
|
E2D_DECLARE_SMART_PTR(EventListener);
|
||||||
E2D_DECLARE_SMART_PTR(Frames);
|
E2D_DECLARE_SMART_PTR(Frames);
|
||||||
|
|
||||||
E2D_DECLARE_SMART_PTR(Geometry);
|
E2D_DECLARE_SMART_PTR(Geometry);
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,6 @@
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
namespace devices
|
|
||||||
{
|
|
||||||
GraphicsDevice::GraphicsDevice()
|
GraphicsDevice::GraphicsDevice()
|
||||||
: fps_text_format_(nullptr)
|
: fps_text_format_(nullptr)
|
||||||
, fps_text_layout_(nullptr)
|
, fps_text_layout_(nullptr)
|
||||||
|
|
@ -516,5 +514,4 @@ namespace easy2d
|
||||||
render_target_ = nullptr;
|
render_target_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,7 @@ namespace easy2d
|
||||||
None // 不启用抗锯齿
|
None // 不启用抗锯齿
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace devices
|
|
||||||
{
|
|
||||||
class GraphicsDevice
|
class GraphicsDevice
|
||||||
: protected Noncopyable
|
: protected Noncopyable
|
||||||
{
|
{
|
||||||
|
|
@ -182,5 +181,4 @@ namespace easy2d
|
||||||
};
|
};
|
||||||
|
|
||||||
E2D_DECLARE_SINGLETON_TYPE(GraphicsDevice, Graphics);
|
E2D_DECLARE_SINGLETON_TYPE(GraphicsDevice, Graphics);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,6 @@ namespace easy2d
|
||||||
|
|
||||||
GetContentScale(&scale_x, &scale_y);
|
GetContentScale(&scale_x, &scale_y);
|
||||||
|
|
||||||
|
|
||||||
Rect client_rect = LocateWindow(width, height, scale_x, scale_y);
|
Rect client_rect = LocateWindow(width, height, scale_x, scale_y);
|
||||||
handle = ::CreateWindowEx(
|
handle = ::CreateWindowEx(
|
||||||
NULL,
|
NULL,
|
||||||
|
|
@ -197,6 +196,12 @@ namespace easy2d
|
||||||
return scale_y;
|
return scale_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WindowImpl::Destroy()
|
||||||
|
{
|
||||||
|
if (handle)
|
||||||
|
::DestroyWindow(handle);
|
||||||
|
}
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
void GetContentScale(float* scale_x, float* scale_y)
|
void GetContentScale(float* scale_x, float* scale_y)
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,8 @@ namespace easy2d
|
||||||
|
|
||||||
float GetContentScaleY() const;
|
float GetContentScaleY() const;
|
||||||
|
|
||||||
|
void Destroy();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
WindowImpl();
|
WindowImpl();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,21 +50,13 @@
|
||||||
#include "base/TextStyle.hpp"
|
#include "base/TextStyle.hpp"
|
||||||
|
|
||||||
#include "base/noncopyable.hpp"
|
#include "base/noncopyable.hpp"
|
||||||
|
#include "base/RefCounter.hpp"
|
||||||
#include "base/intrusive/SmartPointer.hpp"
|
#include "base/intrusive/SmartPointer.hpp"
|
||||||
#include "base/intrusive/List.hpp"
|
#include "base/intrusive/List.hpp"
|
||||||
|
|
||||||
#include "base/RefCounter.hpp"
|
|
||||||
#include "base/ObjectBase.h"
|
#include "base/ObjectBase.h"
|
||||||
#include "base/Unit.h"
|
|
||||||
#include "base/Geometry.h"
|
|
||||||
#include "base/Image.h"
|
#include "base/Image.h"
|
||||||
#include "base/Frames.h"
|
#include "base/Frames.h"
|
||||||
#include "base/Node.h"
|
|
||||||
#include "base/Scene.h"
|
|
||||||
#include "base/Sprite.h"
|
|
||||||
#include "base/Text.h"
|
|
||||||
#include "base/Canvas.h"
|
|
||||||
#include "base/GeometryNode.h"
|
|
||||||
#include "base/Music.h"
|
#include "base/Music.h"
|
||||||
#include "base/Task.h"
|
#include "base/Task.h"
|
||||||
#include "base/Action.hpp"
|
#include "base/Action.hpp"
|
||||||
|
|
@ -73,10 +65,24 @@
|
||||||
#include "base/Animation.h"
|
#include "base/Animation.h"
|
||||||
#include "base/Delay.h"
|
#include "base/Delay.h"
|
||||||
#include "base/Transition.h"
|
#include "base/Transition.h"
|
||||||
#include "base/Debuger.h"
|
#include "base/TaskManager.h"
|
||||||
|
#include "base/ActionManager.h"
|
||||||
|
|
||||||
#include "base/KeyEvent.h"
|
#include "base/Event.hpp"
|
||||||
#include "base/MouseEvent.h"
|
#include "base/MouseEvent.hpp"
|
||||||
|
#include "base/KeyEvent.hpp"
|
||||||
|
#include "base/EventListener.h"
|
||||||
|
#include "base/EventDispatcher.h"
|
||||||
|
|
||||||
|
#include "base/Unit.h"
|
||||||
|
#include "base/Geometry.h"
|
||||||
|
#include "base/Node.h"
|
||||||
|
#include "base/Scene.h"
|
||||||
|
#include "base/Sprite.h"
|
||||||
|
#include "base/Text.h"
|
||||||
|
#include "base/Canvas.h"
|
||||||
|
#include "base/GeometryNode.h"
|
||||||
|
#include "base/Debuger.h"
|
||||||
|
|
||||||
#include "base/Factory.h"
|
#include "base/Factory.h"
|
||||||
#include "base/Game.h"
|
#include "base/Game.h"
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#include "Button.h"
|
#include "Button.h"
|
||||||
#include "../base/input.h"
|
#include "../base/MouseEvent.hpp"
|
||||||
|
|
||||||
#define SAFE_SET(pointer, func, ...) if (pointer) { pointer->##func(__VA_ARGS__); }
|
#define SAFE_SET(pointer, func, ...) if (pointer) { pointer->##func(__VA_ARGS__); }
|
||||||
|
|
||||||
|
|
@ -171,12 +171,15 @@ namespace easy2d
|
||||||
SAFE_SET(disabled_, SetPivot, pivot_x, pivot_y);
|
SAFE_SET(disabled_, SetPivot, pivot_x, pivot_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Button::Dispatch(const MouseEvent & e, bool handled)
|
void Button::HandleEvent(Event* e)
|
||||||
{
|
{
|
||||||
if (!handled && enabled_ && IsVisible() && normal_)
|
if (e && MouseEvent::Check(e) && !e->has_target)
|
||||||
{
|
{
|
||||||
bool contains = normal_->ContainsPoint(e.GetPosition());
|
MouseEvent* me = static_cast<MouseEvent*>(e);
|
||||||
if (e.GetType() == MouseEvent::Type::LeftUp && is_selected_ && contains)
|
if (enabled_ && IsVisible() && normal_)
|
||||||
|
{
|
||||||
|
bool contains = normal_->ContainsPoint(Point{ me->x, me->y });
|
||||||
|
if (me->type == MouseEvent::Up && is_selected_ && contains)
|
||||||
{
|
{
|
||||||
if (callback_)
|
if (callback_)
|
||||||
{
|
{
|
||||||
|
|
@ -184,40 +187,39 @@ namespace easy2d
|
||||||
}
|
}
|
||||||
is_selected_ = false;
|
is_selected_ = false;
|
||||||
SetStatus(Status::Normal);
|
SetStatus(Status::Normal);
|
||||||
return true;
|
me->has_target = true;
|
||||||
}
|
}
|
||||||
else if (e.GetType() == MouseEvent::Type::LeftDown)
|
else if (me->type == MouseEvent::Down)
|
||||||
{
|
{
|
||||||
is_selected_ = contains;
|
is_selected_ = contains;
|
||||||
SetStatus(contains ? Status::Selected : Status::Normal);
|
SetStatus(contains ? Status::Selected : Status::Normal);
|
||||||
|
|
||||||
if (contains)
|
me->has_target = contains;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else if (e.GetType() == MouseEvent::Type::LeftUp)
|
else if (me->type == MouseEvent::Up)
|
||||||
{
|
{
|
||||||
is_selected_ = false;
|
is_selected_ = false;
|
||||||
}
|
}
|
||||||
else if (e.GetType() == MouseEvent::Type::Move && is_selected_ && contains)
|
else if (me->type == MouseEvent::Move && is_selected_ && contains)
|
||||||
{
|
{
|
||||||
SetStatus(Status::Selected);
|
SetStatus(Status::Selected);
|
||||||
return true;
|
me->has_target = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!e.IsLButtonDown() && is_selected_)
|
if (!me->button_down && is_selected_)
|
||||||
{
|
{
|
||||||
is_selected_ = false;
|
is_selected_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetStatus(contains ? Status::Mouseover : Status::Normal);
|
SetStatus(contains ? Status::Mouseover : Status::Normal);
|
||||||
|
|
||||||
if (contains)
|
me->has_target = contains;
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Node::Dispatch(e, handled);
|
Node::HandleEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Button::SetStatus(Status status)
|
void Button::SetStatus(Status status)
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,8 @@ namespace easy2d
|
||||||
float pivot_y
|
float pivot_y
|
||||||
) override;
|
) override;
|
||||||
|
|
||||||
|
virtual void HandleEvent(Event* e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// 按钮状态枚举
|
// 按钮状态枚举
|
||||||
enum class Status { Normal, Mouseover, Selected };
|
enum class Status { Normal, Mouseover, Selected };
|
||||||
|
|
@ -114,12 +116,6 @@ namespace easy2d
|
||||||
// 刷新按钮显示
|
// 刷新按钮显示
|
||||||
virtual void UpdateVisible();
|
virtual void UpdateVisible();
|
||||||
|
|
||||||
// 分发鼠标消息
|
|
||||||
virtual bool Dispatch(
|
|
||||||
const MouseEvent& e,
|
|
||||||
bool handled
|
|
||||||
) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
spNode normal_;
|
spNode normal_;
|
||||||
spNode mouseover_;
|
spNode mouseover_;
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,9 @@
|
||||||
<ClInclude Include="..\..\core\base\d2dres.hpp" />
|
<ClInclude Include="..\..\core\base\d2dres.hpp" />
|
||||||
<ClInclude Include="..\..\core\base\Debuger.h" />
|
<ClInclude Include="..\..\core\base\Debuger.h" />
|
||||||
<ClInclude Include="..\..\core\base\Delay.h" />
|
<ClInclude Include="..\..\core\base\Delay.h" />
|
||||||
|
<ClInclude Include="..\..\core\base\Event.hpp" />
|
||||||
|
<ClInclude Include="..\..\core\base\EventDispatcher.h" />
|
||||||
|
<ClInclude Include="..\..\core\base\EventListener.h" />
|
||||||
<ClInclude Include="..\..\core\base\Factory.h" />
|
<ClInclude Include="..\..\core\base\Factory.h" />
|
||||||
<ClInclude Include="..\..\core\base\Font.hpp" />
|
<ClInclude Include="..\..\core\base\Font.hpp" />
|
||||||
<ClInclude Include="..\..\core\base\Frames.h" />
|
<ClInclude Include="..\..\core\base\Frames.h" />
|
||||||
|
|
@ -42,11 +45,11 @@
|
||||||
<ClInclude Include="..\..\core\base\Input.h" />
|
<ClInclude Include="..\..\core\base\Input.h" />
|
||||||
<ClInclude Include="..\..\core\base\intrusive\List.hpp" />
|
<ClInclude Include="..\..\core\base\intrusive\List.hpp" />
|
||||||
<ClInclude Include="..\..\core\base\intrusive\SmartPointer.hpp" />
|
<ClInclude Include="..\..\core\base\intrusive\SmartPointer.hpp" />
|
||||||
<ClInclude Include="..\..\core\base\KeyEvent.h" />
|
<ClInclude Include="..\..\core\base\KeyEvent.hpp" />
|
||||||
<ClInclude Include="..\..\core\base\logs.h" />
|
<ClInclude Include="..\..\core\base\logs.h" />
|
||||||
<ClInclude Include="..\..\core\base\macros.h" />
|
<ClInclude Include="..\..\core\base\macros.h" />
|
||||||
<ClInclude Include="..\..\core\base\modules.h" />
|
<ClInclude Include="..\..\core\base\modules.h" />
|
||||||
<ClInclude Include="..\..\core\base\MouseEvent.h" />
|
<ClInclude Include="..\..\core\base\MouseEvent.hpp" />
|
||||||
<ClInclude Include="..\..\core\base\Music.h" />
|
<ClInclude Include="..\..\core\base\Music.h" />
|
||||||
<ClInclude Include="..\..\core\base\Node.h" />
|
<ClInclude Include="..\..\core\base\Node.h" />
|
||||||
<ClInclude Include="..\..\core\base\noncopyable.hpp" />
|
<ClInclude Include="..\..\core\base\noncopyable.hpp" />
|
||||||
|
|
@ -96,6 +99,8 @@
|
||||||
<ClCompile Include="..\..\core\base\Color.cpp" />
|
<ClCompile Include="..\..\core\base\Color.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Debuger.cpp" />
|
<ClCompile Include="..\..\core\base\Debuger.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Delay.cpp" />
|
<ClCompile Include="..\..\core\base\Delay.cpp" />
|
||||||
|
<ClCompile Include="..\..\core\base\EventDispatcher.cpp" />
|
||||||
|
<ClCompile Include="..\..\core\base\EventListener.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Factory.cpp" />
|
<ClCompile Include="..\..\core\base\Factory.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Frames.cpp" />
|
<ClCompile Include="..\..\core\base\Frames.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Game.cpp" />
|
<ClCompile Include="..\..\core\base\Game.cpp" />
|
||||||
|
|
@ -103,10 +108,8 @@
|
||||||
<ClCompile Include="..\..\core\base\GeometryNode.cpp" />
|
<ClCompile Include="..\..\core\base\GeometryNode.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Image.cpp" />
|
<ClCompile Include="..\..\core\base\Image.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Input.cpp" />
|
<ClCompile Include="..\..\core\base\Input.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\KeyEvent.cpp" />
|
|
||||||
<ClCompile Include="..\..\core\base\logs.cpp" />
|
<ClCompile Include="..\..\core\base\logs.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\modules.cpp" />
|
<ClCompile Include="..\..\core\base\modules.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\MouseEvent.cpp" />
|
|
||||||
<ClCompile Include="..\..\core\base\Music.cpp" />
|
<ClCompile Include="..\..\core\base\Music.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Node.cpp" />
|
<ClCompile Include="..\..\core\base\Node.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\ObjectBase.cpp" />
|
<ClCompile Include="..\..\core\base\ObjectBase.cpp" />
|
||||||
|
|
|
||||||
|
|
@ -71,12 +71,6 @@
|
||||||
<ClInclude Include="..\..\core\base\window.h">
|
<ClInclude Include="..\..\core\base\window.h">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\core\base\KeyEvent.h">
|
|
||||||
<Filter>base</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\core\base\MouseEvent.h">
|
|
||||||
<Filter>base</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\core\math\Matrix.hpp">
|
<ClInclude Include="..\..\core\math\Matrix.hpp">
|
||||||
<Filter>math</Filter>
|
<Filter>math</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|
@ -197,6 +191,21 @@
|
||||||
<ClInclude Include="..\..\core\base\Factory.h">
|
<ClInclude Include="..\..\core\base\Factory.h">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\core\base\EventDispatcher.h">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\core\base\Event.hpp">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\core\base\KeyEvent.hpp">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\core\base\MouseEvent.hpp">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\core\base\EventListener.h">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Filter Include="base">
|
<Filter Include="base">
|
||||||
|
|
@ -276,12 +285,6 @@
|
||||||
<ClCompile Include="..\..\core\base\window.cpp">
|
<ClCompile Include="..\..\core\base\window.cpp">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\core\base\KeyEvent.cpp">
|
|
||||||
<Filter>base</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\core\base\MouseEvent.cpp">
|
|
||||||
<Filter>base</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\core\math\rand.cpp">
|
<ClCompile Include="..\..\core\math\rand.cpp">
|
||||||
<Filter>math</Filter>
|
<Filter>math</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
@ -348,5 +351,11 @@
|
||||||
<ClCompile Include="..\..\core\base\Factory.cpp">
|
<ClCompile Include="..\..\core\base\Factory.cpp">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\core\base\EventDispatcher.cpp">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\core\base\EventListener.cpp">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -32,6 +32,9 @@
|
||||||
<ClInclude Include="..\..\core\base\d2dres.hpp" />
|
<ClInclude Include="..\..\core\base\d2dres.hpp" />
|
||||||
<ClInclude Include="..\..\core\base\Debuger.h" />
|
<ClInclude Include="..\..\core\base\Debuger.h" />
|
||||||
<ClInclude Include="..\..\core\base\Delay.h" />
|
<ClInclude Include="..\..\core\base\Delay.h" />
|
||||||
|
<ClInclude Include="..\..\core\base\Event.hpp" />
|
||||||
|
<ClInclude Include="..\..\core\base\EventDispatcher.h" />
|
||||||
|
<ClInclude Include="..\..\core\base\EventListener.h" />
|
||||||
<ClInclude Include="..\..\core\base\Factory.h" />
|
<ClInclude Include="..\..\core\base\Factory.h" />
|
||||||
<ClInclude Include="..\..\core\base\Font.hpp" />
|
<ClInclude Include="..\..\core\base\Font.hpp" />
|
||||||
<ClInclude Include="..\..\core\base\Frames.h" />
|
<ClInclude Include="..\..\core\base\Frames.h" />
|
||||||
|
|
@ -42,11 +45,11 @@
|
||||||
<ClInclude Include="..\..\core\base\Input.h" />
|
<ClInclude Include="..\..\core\base\Input.h" />
|
||||||
<ClInclude Include="..\..\core\base\intrusive\List.hpp" />
|
<ClInclude Include="..\..\core\base\intrusive\List.hpp" />
|
||||||
<ClInclude Include="..\..\core\base\intrusive\SmartPointer.hpp" />
|
<ClInclude Include="..\..\core\base\intrusive\SmartPointer.hpp" />
|
||||||
<ClInclude Include="..\..\core\base\KeyEvent.h" />
|
<ClInclude Include="..\..\core\base\KeyEvent.hpp" />
|
||||||
<ClInclude Include="..\..\core\base\logs.h" />
|
<ClInclude Include="..\..\core\base\logs.h" />
|
||||||
<ClInclude Include="..\..\core\base\macros.h" />
|
<ClInclude Include="..\..\core\base\macros.h" />
|
||||||
<ClInclude Include="..\..\core\base\modules.h" />
|
<ClInclude Include="..\..\core\base\modules.h" />
|
||||||
<ClInclude Include="..\..\core\base\MouseEvent.h" />
|
<ClInclude Include="..\..\core\base\MouseEvent.hpp" />
|
||||||
<ClInclude Include="..\..\core\base\Music.h" />
|
<ClInclude Include="..\..\core\base\Music.h" />
|
||||||
<ClInclude Include="..\..\core\base\Node.h" />
|
<ClInclude Include="..\..\core\base\Node.h" />
|
||||||
<ClInclude Include="..\..\core\base\noncopyable.hpp" />
|
<ClInclude Include="..\..\core\base\noncopyable.hpp" />
|
||||||
|
|
@ -96,6 +99,8 @@
|
||||||
<ClCompile Include="..\..\core\base\Color.cpp" />
|
<ClCompile Include="..\..\core\base\Color.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Debuger.cpp" />
|
<ClCompile Include="..\..\core\base\Debuger.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Delay.cpp" />
|
<ClCompile Include="..\..\core\base\Delay.cpp" />
|
||||||
|
<ClCompile Include="..\..\core\base\EventDispatcher.cpp" />
|
||||||
|
<ClCompile Include="..\..\core\base\EventListener.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Factory.cpp" />
|
<ClCompile Include="..\..\core\base\Factory.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Frames.cpp" />
|
<ClCompile Include="..\..\core\base\Frames.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Game.cpp" />
|
<ClCompile Include="..\..\core\base\Game.cpp" />
|
||||||
|
|
@ -103,10 +108,8 @@
|
||||||
<ClCompile Include="..\..\core\base\GeometryNode.cpp" />
|
<ClCompile Include="..\..\core\base\GeometryNode.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Image.cpp" />
|
<ClCompile Include="..\..\core\base\Image.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Input.cpp" />
|
<ClCompile Include="..\..\core\base\Input.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\KeyEvent.cpp" />
|
|
||||||
<ClCompile Include="..\..\core\base\logs.cpp" />
|
<ClCompile Include="..\..\core\base\logs.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\modules.cpp" />
|
<ClCompile Include="..\..\core\base\modules.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\MouseEvent.cpp" />
|
|
||||||
<ClCompile Include="..\..\core\base\Music.cpp" />
|
<ClCompile Include="..\..\core\base\Music.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Node.cpp" />
|
<ClCompile Include="..\..\core\base\Node.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\ObjectBase.cpp" />
|
<ClCompile Include="..\..\core\base\ObjectBase.cpp" />
|
||||||
|
|
|
||||||
|
|
@ -71,12 +71,6 @@
|
||||||
<ClInclude Include="..\..\core\base\window.h">
|
<ClInclude Include="..\..\core\base\window.h">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\core\base\KeyEvent.h">
|
|
||||||
<Filter>base</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\core\base\MouseEvent.h">
|
|
||||||
<Filter>base</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\core\math\Matrix.hpp">
|
<ClInclude Include="..\..\core\math\Matrix.hpp">
|
||||||
<Filter>math</Filter>
|
<Filter>math</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|
@ -197,6 +191,21 @@
|
||||||
<ClInclude Include="..\..\core\base\Factory.h">
|
<ClInclude Include="..\..\core\base\Factory.h">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\core\base\EventDispatcher.h">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\core\base\Event.hpp">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\core\base\KeyEvent.hpp">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\core\base\MouseEvent.hpp">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\core\base\EventListener.h">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Filter Include="base">
|
<Filter Include="base">
|
||||||
|
|
@ -276,12 +285,6 @@
|
||||||
<ClCompile Include="..\..\core\base\window.cpp">
|
<ClCompile Include="..\..\core\base\window.cpp">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\core\base\KeyEvent.cpp">
|
|
||||||
<Filter>base</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\core\base\MouseEvent.cpp">
|
|
||||||
<Filter>base</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\core\math\rand.cpp">
|
<ClCompile Include="..\..\core\math\rand.cpp">
|
||||||
<Filter>math</Filter>
|
<Filter>math</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
@ -348,5 +351,11 @@
|
||||||
<ClCompile Include="..\..\core\base\Factory.cpp">
|
<ClCompile Include="..\..\core\base\Factory.cpp">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\core\base\EventDispatcher.cpp">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\core\base\EventListener.cpp">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -32,6 +32,9 @@
|
||||||
<ClInclude Include="..\..\core\base\d2dres.hpp" />
|
<ClInclude Include="..\..\core\base\d2dres.hpp" />
|
||||||
<ClInclude Include="..\..\core\base\Debuger.h" />
|
<ClInclude Include="..\..\core\base\Debuger.h" />
|
||||||
<ClInclude Include="..\..\core\base\Delay.h" />
|
<ClInclude Include="..\..\core\base\Delay.h" />
|
||||||
|
<ClInclude Include="..\..\core\base\Event.hpp" />
|
||||||
|
<ClInclude Include="..\..\core\base\EventDispatcher.h" />
|
||||||
|
<ClInclude Include="..\..\core\base\EventListener.h" />
|
||||||
<ClInclude Include="..\..\core\base\Factory.h" />
|
<ClInclude Include="..\..\core\base\Factory.h" />
|
||||||
<ClInclude Include="..\..\core\base\Font.hpp" />
|
<ClInclude Include="..\..\core\base\Font.hpp" />
|
||||||
<ClInclude Include="..\..\core\base\Frames.h" />
|
<ClInclude Include="..\..\core\base\Frames.h" />
|
||||||
|
|
@ -42,11 +45,11 @@
|
||||||
<ClInclude Include="..\..\core\base\Input.h" />
|
<ClInclude Include="..\..\core\base\Input.h" />
|
||||||
<ClInclude Include="..\..\core\base\intrusive\List.hpp" />
|
<ClInclude Include="..\..\core\base\intrusive\List.hpp" />
|
||||||
<ClInclude Include="..\..\core\base\intrusive\SmartPointer.hpp" />
|
<ClInclude Include="..\..\core\base\intrusive\SmartPointer.hpp" />
|
||||||
<ClInclude Include="..\..\core\base\KeyEvent.h" />
|
<ClInclude Include="..\..\core\base\KeyEvent.hpp" />
|
||||||
<ClInclude Include="..\..\core\base\logs.h" />
|
<ClInclude Include="..\..\core\base\logs.h" />
|
||||||
<ClInclude Include="..\..\core\base\macros.h" />
|
<ClInclude Include="..\..\core\base\macros.h" />
|
||||||
<ClInclude Include="..\..\core\base\modules.h" />
|
<ClInclude Include="..\..\core\base\modules.h" />
|
||||||
<ClInclude Include="..\..\core\base\MouseEvent.h" />
|
<ClInclude Include="..\..\core\base\MouseEvent.hpp" />
|
||||||
<ClInclude Include="..\..\core\base\Music.h" />
|
<ClInclude Include="..\..\core\base\Music.h" />
|
||||||
<ClInclude Include="..\..\core\base\Node.h" />
|
<ClInclude Include="..\..\core\base\Node.h" />
|
||||||
<ClInclude Include="..\..\core\base\noncopyable.hpp" />
|
<ClInclude Include="..\..\core\base\noncopyable.hpp" />
|
||||||
|
|
@ -96,6 +99,8 @@
|
||||||
<ClCompile Include="..\..\core\base\Color.cpp" />
|
<ClCompile Include="..\..\core\base\Color.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Debuger.cpp" />
|
<ClCompile Include="..\..\core\base\Debuger.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Delay.cpp" />
|
<ClCompile Include="..\..\core\base\Delay.cpp" />
|
||||||
|
<ClCompile Include="..\..\core\base\EventDispatcher.cpp" />
|
||||||
|
<ClCompile Include="..\..\core\base\EventListener.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Factory.cpp" />
|
<ClCompile Include="..\..\core\base\Factory.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Frames.cpp" />
|
<ClCompile Include="..\..\core\base\Frames.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Game.cpp" />
|
<ClCompile Include="..\..\core\base\Game.cpp" />
|
||||||
|
|
@ -103,10 +108,8 @@
|
||||||
<ClCompile Include="..\..\core\base\GeometryNode.cpp" />
|
<ClCompile Include="..\..\core\base\GeometryNode.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Image.cpp" />
|
<ClCompile Include="..\..\core\base\Image.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Input.cpp" />
|
<ClCompile Include="..\..\core\base\Input.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\KeyEvent.cpp" />
|
|
||||||
<ClCompile Include="..\..\core\base\logs.cpp" />
|
<ClCompile Include="..\..\core\base\logs.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\modules.cpp" />
|
<ClCompile Include="..\..\core\base\modules.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\MouseEvent.cpp" />
|
|
||||||
<ClCompile Include="..\..\core\base\Music.cpp" />
|
<ClCompile Include="..\..\core\base\Music.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Node.cpp" />
|
<ClCompile Include="..\..\core\base\Node.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\ObjectBase.cpp" />
|
<ClCompile Include="..\..\core\base\ObjectBase.cpp" />
|
||||||
|
|
|
||||||
|
|
@ -71,12 +71,6 @@
|
||||||
<ClInclude Include="..\..\core\base\window.h">
|
<ClInclude Include="..\..\core\base\window.h">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\core\base\KeyEvent.h">
|
|
||||||
<Filter>base</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\core\base\MouseEvent.h">
|
|
||||||
<Filter>base</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\core\math\Matrix.hpp">
|
<ClInclude Include="..\..\core\math\Matrix.hpp">
|
||||||
<Filter>math</Filter>
|
<Filter>math</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|
@ -197,6 +191,21 @@
|
||||||
<ClInclude Include="..\..\core\base\Factory.h">
|
<ClInclude Include="..\..\core\base\Factory.h">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\core\base\EventDispatcher.h">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\core\base\Event.hpp">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\core\base\KeyEvent.hpp">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\core\base\MouseEvent.hpp">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\core\base\EventListener.h">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Filter Include="base">
|
<Filter Include="base">
|
||||||
|
|
@ -276,12 +285,6 @@
|
||||||
<ClCompile Include="..\..\core\base\window.cpp">
|
<ClCompile Include="..\..\core\base\window.cpp">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\core\base\KeyEvent.cpp">
|
|
||||||
<Filter>base</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\core\base\MouseEvent.cpp">
|
|
||||||
<Filter>base</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\core\math\rand.cpp">
|
<ClCompile Include="..\..\core\math\rand.cpp">
|
||||||
<Filter>math</Filter>
|
<Filter>math</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
@ -348,5 +351,11 @@
|
||||||
<ClCompile Include="..\..\core\base\Factory.cpp">
|
<ClCompile Include="..\..\core\base\Factory.cpp">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\core\base\EventDispatcher.cpp">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\core\base\EventListener.cpp">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
Loading…
Reference in New Issue