diff --git a/appveyor.yml b/appveyor.yml
index 073bdfc0..e876db8b 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -71,7 +71,8 @@ platform:
install:
- ps: .\scripts\appveyor\install_coapp.ps1
-# before_build:
+before_build:
+- ps: .\scripts\appveyor\clear_project_configuration.ps1
# - ps: nuget restore projects/Kiwano.sln
build:
diff --git a/projects/kiwano-audio.vcxproj b/projects/kiwano-audio.vcxproj
index f3593c1a..0deda3e8 100644
--- a/projects/kiwano-audio.vcxproj
+++ b/projects/kiwano-audio.vcxproj
@@ -75,7 +75,7 @@
Level3
Disabled
true
- None
+ EditAndContinue
true
../src/
false
@@ -93,7 +93,7 @@
true
false
true
- None
+ EditAndContinue
true
../src/
false
diff --git a/projects/kiwano-imgui.vcxproj b/projects/kiwano-imgui.vcxproj
index 1ece0103..5416cc13 100644
--- a/projects/kiwano-imgui.vcxproj
+++ b/projects/kiwano-imgui.vcxproj
@@ -84,7 +84,7 @@
Level3
Disabled
true
- None
+ EditAndContinue
true
../src/
false
@@ -102,7 +102,7 @@
true
false
true
- None
+ EditAndContinue
true
../src/
false
diff --git a/projects/kiwano-network.vcxproj b/projects/kiwano-network.vcxproj
index bf1c120c..1568fb4e 100644
--- a/projects/kiwano-network.vcxproj
+++ b/projects/kiwano-network.vcxproj
@@ -73,7 +73,7 @@
Level3
Disabled
true
- None
+ EditAndContinue
true
../src/
false
@@ -91,7 +91,7 @@
true
false
true
- None
+ EditAndContinue
true
../src/
false
diff --git a/projects/kiwano.vcxproj b/projects/kiwano.vcxproj
index 39a9021c..6284642f 100644
--- a/projects/kiwano.vcxproj
+++ b/projects/kiwano.vcxproj
@@ -21,6 +21,7 @@
+
diff --git a/projects/kiwano.vcxproj.filters b/projects/kiwano.vcxproj.filters
index 8995881e..7dadb0ef 100644
--- a/projects/kiwano.vcxproj.filters
+++ b/projects/kiwano.vcxproj.filters
@@ -306,6 +306,9 @@
renderer
+
+ core
+
diff --git a/scripts/appveyor/clear_project_configuration.ps1 b/scripts/appveyor/clear_project_configuration.ps1
new file mode 100644
index 00000000..04be8f36
--- /dev/null
+++ b/scripts/appveyor/clear_project_configuration.ps1
@@ -0,0 +1,8 @@
+$replace = "EditAndContinue"
+$replaceTo = "None"
+
+Get-ChildItem -Path 'projects\' *.vcxproj | ForEach-Object {
+ $filePath = 'projects\' + $_
+ Copy-Item -Path $filePath -Destination ($filePath + '.template')
+ Get-Content ($filePath + '.template') | ForEach-Object { $_ -replace $replace, $replaceTo } > $filePath
+}
diff --git a/src/kiwano-audio/src/Player.cpp b/src/kiwano-audio/src/Player.cpp
index a7a862bf..5e696ec0 100644
--- a/src/kiwano-audio/src/Player.cpp
+++ b/src/kiwano-audio/src/Player.cpp
@@ -34,9 +34,9 @@ namespace kiwano
ClearCache();
}
- size_t Player::Load(String const& file_path)
+ UInt32 Player::Load(String const& file_path)
{
- size_t hash_code = file_path.hash();
+ UInt32 hash_code = file_path.hash();
if (sound_cache_.end() != sound_cache_.find(hash_code))
return true;
@@ -54,9 +54,9 @@ namespace kiwano
return false;
}
- size_t Player::Load(Resource const& res)
+ UInt32 Player::Load(Resource const& res)
{
- size_t hash_code = res.GetId();
+ UInt32 hash_code = res.GetId();
if (sound_cache_.end() != sound_cache_.find(hash_code))
return true;
@@ -74,35 +74,35 @@ namespace kiwano
return false;
}
- void Player::Play(size_t id, int loop_count)
+ void Player::Play(UInt32 id, Int32 loop_count)
{
auto iter = sound_cache_.find(id);
if (sound_cache_.end() != iter)
iter->second->Play(loop_count);
}
- void Player::Pause(size_t id)
+ void Player::Pause(UInt32 id)
{
auto iter = sound_cache_.find(id);
if (sound_cache_.end() != iter)
iter->second->Pause();
}
- void Player::Resume(size_t id)
+ void Player::Resume(UInt32 id)
{
auto iter = sound_cache_.find(id);
if (sound_cache_.end() != iter)
iter->second->Resume();
}
- void Player::Stop(size_t id)
+ void Player::Stop(UInt32 id)
{
auto iter = sound_cache_.find(id);
if (sound_cache_.end() != iter)
iter->second->Stop();
}
- bool Player::IsPlaying(size_t id)
+ bool Player::IsPlaying(UInt32 id)
{
auto iter = sound_cache_.find(id);
if (sound_cache_.end() != iter)
@@ -110,12 +110,12 @@ namespace kiwano
return false;
}
- float Player::GetVolume() const
+ Float32 Player::GetVolume() const
{
return volume_;
}
- void Player::SetVolume(float volume)
+ void Player::SetVolume(Float32 volume)
{
volume_ = std::min(std::max(volume, -224.f), 224.f);
for (const auto& pair : sound_cache_)
diff --git a/src/kiwano-audio/src/Player.h b/src/kiwano-audio/src/Player.h
index 8ad90766..7e33e2d0 100644
--- a/src/kiwano-audio/src/Player.h
+++ b/src/kiwano-audio/src/Player.h
@@ -39,47 +39,47 @@ namespace kiwano
~Player();
// 加载本地音频文件, 返回该资源标识符
- size_t Load(
+ UInt32 Load(
String const& file_path
);
// 加载音乐资源, 返回该资源标识符
- size_t Load(
+ UInt32 Load(
Resource const& res /* 音乐资源 */
);
// 播放音乐
void Play(
- size_t id, /* 标识符 */
- int loop_count = 0 /* 播放循环次数 (-1 为循环播放) */
+ UInt32 id, /* 标识符 */
+ Int32 loop_count = 0 /* 播放循环次数 (-1 为循环播放) */
);
// 暂停音乐
void Pause(
- size_t id /* 标识符 */
+ UInt32 id /* 标识符 */
);
// 继续播放音乐
void Resume(
- size_t id /* 标识符 */
+ UInt32 id /* 标识符 */
);
// 停止音乐
void Stop(
- size_t id /* 标识符 */
+ UInt32 id /* 标识符 */
);
// 获取音乐播放状态
bool IsPlaying(
- size_t id /* 标识符 */
+ UInt32 id /* 标识符 */
);
// 获取音量
- float GetVolume() const;
+ Float32 GetVolume() const;
// 设置音量
void SetVolume(
- float volume /* 1.0 为原始音量 */
+ Float32 volume /* 1.0 为原始音量 */
);
// 暂停所有音乐
@@ -95,9 +95,9 @@ namespace kiwano
void ClearCache();
protected:
- float volume_;
+ Float32 volume_;
- using MusicMap = Map;
+ using MusicMap = Map;
MusicMap sound_cache_;
};
}
diff --git a/src/kiwano-audio/src/Sound.cpp b/src/kiwano-audio/src/Sound.cpp
index cf2c9c2e..04bc7920 100644
--- a/src/kiwano-audio/src/Sound.cpp
+++ b/src/kiwano-audio/src/Sound.cpp
@@ -121,7 +121,7 @@ namespace kiwano
return true;
}
- void Sound::Play(int loop_count)
+ void Sound::Play(Int32 loop_count)
{
if (!opened_)
{
@@ -144,7 +144,7 @@ namespace kiwano
buffer.pAudioData = wave_data_;
buffer.Flags = XAUDIO2_END_OF_STREAM;
buffer.AudioBytes = size_;
- buffer.LoopCount = static_cast(loop_count);
+ buffer.LoopCount = static_cast(loop_count);
HRESULT hr = voice_->SubmitSourceBuffer(&buffer);
if (SUCCEEDED(hr))
@@ -221,7 +221,7 @@ namespace kiwano
XAUDIO2_VOICE_STATE state;
voice_->GetState(&state);
- UINT32 buffers_queued = state.BuffersQueued;
+ UInt32 buffers_queued = state.BuffersQueued;
if (buffers_queued && playing_)
return true;
@@ -229,16 +229,16 @@ namespace kiwano
return false;
}
- float Sound::GetVolume() const
+ Float32 Sound::GetVolume() const
{
KGE_ASSERT(voice_ != nullptr && "IXAudio2SourceVoice* is NULL");
- float volume = 0.0f;
+ Float32 volume = 0.0f;
voice_->GetVolume(&volume);
return volume;
}
- void Sound::SetVolume(float volume)
+ void Sound::SetVolume(Float32 volume)
{
KGE_ASSERT(voice_ != nullptr && "IXAudio2SourceVoice* is NULL");
diff --git a/src/kiwano-audio/src/Sound.h b/src/kiwano-audio/src/Sound.h
index d39f457f..bff2118c 100644
--- a/src/kiwano-audio/src/Sound.h
+++ b/src/kiwano-audio/src/Sound.h
@@ -59,7 +59,7 @@ namespace kiwano
// 播放
void Play(
- int loop_count = 0 /* 播放循环次数 (-1 为循环播放) */
+ Int32 loop_count = 0 /* 播放循环次数 (-1 为循环播放) */
);
// 暂停
@@ -78,17 +78,17 @@ namespace kiwano
bool IsPlaying() const;
// 获取音量
- float GetVolume() const;
+ Float32 GetVolume() const;
// 设置音量
void SetVolume(
- float volume /* 1 为原始音量, 大于 1 为放大音量, 0 为最小音量 */
+ Float32 volume /* 1 为原始音量, 大于 1 为放大音量, 0 为最小音量 */
);
protected:
bool opened_;
bool playing_;
- UINT32 size_;
+ UInt32 size_;
BYTE* wave_data_;
IXAudio2SourceVoice* voice_;
};
diff --git a/src/kiwano-audio/src/Transcoder.cpp b/src/kiwano-audio/src/Transcoder.cpp
index 0e38305e..a07dca56 100644
--- a/src/kiwano-audio/src/Transcoder.cpp
+++ b/src/kiwano-audio/src/Transcoder.cpp
@@ -55,7 +55,7 @@ namespace kiwano
return wave_format_;
}
- HRESULT Transcoder::LoadMediaFile(String const& file_path, BYTE** wave_data, UINT32* wave_data_size)
+ HRESULT Transcoder::LoadMediaFile(String const& file_path, BYTE** wave_data, UInt32* wave_data_size)
{
HRESULT hr = S_OK;
@@ -75,7 +75,7 @@ namespace kiwano
return hr;
}
- HRESULT Transcoder::LoadMediaResource(Resource const& res, BYTE** wave_data, UINT32* wave_data_size)
+ HRESULT Transcoder::LoadMediaResource(Resource const& res, BYTE** wave_data, UInt32* wave_data_size)
{
HRESULT hr = S_OK;
@@ -88,7 +88,7 @@ namespace kiwano
stream = kiwano::modules::Shlwapi::Get().SHCreateMemStream(
static_cast(data.buffer),
- static_cast(data.size)
+ static_cast(data.size)
);
if (stream == nullptr)
@@ -119,7 +119,7 @@ namespace kiwano
return hr;
}
- HRESULT Transcoder::ReadSource(IMFSourceReader* reader, BYTE** wave_data, UINT32* wave_data_size)
+ HRESULT Transcoder::ReadSource(IMFSourceReader* reader, BYTE** wave_data, UInt32* wave_data_size)
{
HRESULT hr = S_OK;
DWORD max_stream_size = 0;
@@ -170,7 +170,7 @@ namespace kiwano
// 获取 WAVEFORMAT 数据
if (SUCCEEDED(hr))
{
- UINT32 size = 0;
+ UInt32 size = 0;
hr = modules::MediaFoundation::Get().MFCreateWaveFormatExFromMFMediaType(
uncompressed_type.get(),
&wave_format_,
diff --git a/src/kiwano-audio/src/Transcoder.h b/src/kiwano-audio/src/Transcoder.h
index 3b96b498..9bc02cb4 100644
--- a/src/kiwano-audio/src/Transcoder.h
+++ b/src/kiwano-audio/src/Transcoder.h
@@ -40,19 +40,19 @@ namespace kiwano
HRESULT LoadMediaFile(
String const& file_path,
BYTE** wave_data,
- UINT32* wave_data_size
+ UInt32* wave_data_size
);
HRESULT LoadMediaResource(
Resource const& res,
BYTE** wave_data,
- UINT32* wave_data_size
+ UInt32* wave_data_size
);
HRESULT ReadSource(
IMFSourceReader* reader,
BYTE** wave_data,
- UINT32* wave_data_size
+ UInt32* wave_data_size
);
private:
diff --git a/src/kiwano-audio/src/audio-modules.h b/src/kiwano-audio/src/audio-modules.h
index 689ba0dd..90c95773 100644
--- a/src/kiwano-audio/src/audio-modules.h
+++ b/src/kiwano-audio/src/audio-modules.h
@@ -37,7 +37,7 @@ namespace kiwano
HMODULE xaudio2;
// XAudio2 functions
- typedef HRESULT(WINAPI* PFN_XAudio2Create)(IXAudio2**, UINT32, XAUDIO2_PROCESSOR);
+ typedef HRESULT(WINAPI* PFN_XAudio2Create)(IXAudio2**, UInt32, XAUDIO2_PROCESSOR);
public:
static inline XAudio2& Get()
@@ -61,7 +61,7 @@ namespace kiwano
typedef HRESULT(WINAPI* PFN_MFStartup)(ULONG, DWORD);
typedef HRESULT(WINAPI* PFN_MFShutdown)();
typedef HRESULT(WINAPI* PFN_MFCreateMediaType)(IMFMediaType**);
- typedef HRESULT(WINAPI* PFN_MFCreateWaveFormatExFromMFMediaType)(IMFMediaType*, WAVEFORMATEX**, UINT32*, UINT32);
+ typedef HRESULT(WINAPI* PFN_MFCreateWaveFormatExFromMFMediaType)(IMFMediaType*, WAVEFORMATEX**, UInt32*, UInt32);
typedef HRESULT(WINAPI* PFN_MFCreateSourceReaderFromURL)(LPCWSTR, IMFAttributes*, IMFSourceReader**);
typedef HRESULT(WINAPI* PFN_MFCreateSourceReaderFromByteStream)(IMFByteStream*, IMFAttributes*, IMFSourceReader**);
typedef HRESULT(WINAPI* PFN_MFCreateMFByteStreamOnStream)(IStream*, IMFByteStream**);
diff --git a/src/kiwano-imgui/src/ImGuiModule.cpp b/src/kiwano-imgui/src/ImGuiModule.cpp
index cd8eca18..7a571cdd 100644
--- a/src/kiwano-imgui/src/ImGuiModule.cpp
+++ b/src/kiwano-imgui/src/ImGuiModule.cpp
@@ -119,7 +119,7 @@ namespace kiwano
Render();
}
- void ImGuiModule::HandleMessage(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
+ void ImGuiModule::HandleMessage(HWND hwnd, UInt32 msg, WPARAM wparam, LPARAM lparam)
{
if (ImGui::GetCurrentContext() == NULL)
return;
@@ -132,7 +132,7 @@ namespace kiwano
case WM_MBUTTONDOWN: case WM_MBUTTONDBLCLK:
case WM_XBUTTONDOWN: case WM_XBUTTONDBLCLK:
{
- int button = 0;
+ Int32 button = 0;
if (msg == WM_LBUTTONDOWN || msg == WM_LBUTTONDBLCLK) { button = 0; }
if (msg == WM_RBUTTONDOWN || msg == WM_RBUTTONDBLCLK) { button = 1; }
if (msg == WM_MBUTTONDOWN || msg == WM_MBUTTONDBLCLK) { button = 2; }
@@ -148,7 +148,7 @@ namespace kiwano
case WM_MBUTTONUP:
case WM_XBUTTONUP:
{
- int button = 0;
+ Int32 button = 0;
if (msg == WM_LBUTTONUP) { button = 0; }
if (msg == WM_RBUTTONUP) { button = 1; }
if (msg == WM_MBUTTONUP) { button = 2; }
@@ -160,12 +160,12 @@ namespace kiwano
}
case WM_MOUSEWHEEL:
{
- io.MouseWheel += (float)GET_WHEEL_DELTA_WPARAM(wparam) / (float)WHEEL_DELTA;
+ io.MouseWheel += (Float32)GET_WHEEL_DELTA_WPARAM(wparam) / (Float32)WHEEL_DELTA;
break;
}
case WM_MOUSEHWHEEL:
{
- io.MouseWheelH += (float)GET_WHEEL_DELTA_WPARAM(wparam) / (float)WHEEL_DELTA;
+ io.MouseWheelH += (Float32)GET_WHEEL_DELTA_WPARAM(wparam) / (Float32)WHEEL_DELTA;
break;
}
case WM_KEYDOWN:
@@ -185,7 +185,7 @@ namespace kiwano
case WM_CHAR:
{
// You can also use ToAscii()+GetKeyboardState() to retrieve characters.
- io.AddInputCharacter((unsigned int)wparam);
+ io.AddInputCharacter((UInt32)wparam);
break;
}
case WM_SETCURSOR:
@@ -198,7 +198,7 @@ namespace kiwano
}
case WM_DEVICECHANGE:
{
- if ((UINT)wparam == DBT_DEVNODES_CHANGED)
+ if ((UInt32)wparam == DBT_DEVNODES_CHANGED)
want_update_has_gamepad_ = true;
break;
}
@@ -233,7 +233,7 @@ namespace kiwano
// Set OS mouse position if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
if (io.WantSetMousePos)
{
- POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y };
+ POINT pos = { (Int32)io.MousePos.x, (Int32)io.MousePos.y };
::ClientToScreen(target_window_, &pos);
::SetCursorPos(pos.x, pos.y);
}
@@ -286,7 +286,7 @@ namespace kiwano
io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
#define MAP_BUTTON(NAV_NO, BUTTON_ENUM) { io.NavInputs[NAV_NO] = (gamepad.wButtons & BUTTON_ENUM) ? 1.0f : 0.0f; }
-#define MAP_ANALOG(NAV_NO, VALUE, V0, V1) { float vn = (float)(VALUE - V0) / (float)(V1 - V0); if (vn > 1.0f) vn = 1.0f; if (vn > 0.0f && io.NavInputs[NAV_NO] < vn) io.NavInputs[NAV_NO] = vn; }
+#define MAP_ANALOG(NAV_NO, VALUE, V0, V1) { Float32 vn = (Float32)(VALUE - V0) / (Float32)(V1 - V0); if (vn > 1.0f) vn = 1.0f; if (vn > 0.0f && io.NavInputs[NAV_NO] < vn) io.NavInputs[NAV_NO] = vn; }
MAP_BUTTON(ImGuiNavInput_Activate, XINPUT_GAMEPAD_A); // Cross / A
MAP_BUTTON(ImGuiNavInput_Cancel, XINPUT_GAMEPAD_B); // Circle / B
MAP_BUTTON(ImGuiNavInput_Menu, XINPUT_GAMEPAD_X); // Square / X
diff --git a/src/kiwano-imgui/src/ImGuiModule.h b/src/kiwano-imgui/src/ImGuiModule.h
index 553afc11..6883edcc 100644
--- a/src/kiwano-imgui/src/ImGuiModule.h
+++ b/src/kiwano-imgui/src/ImGuiModule.h
@@ -52,7 +52,7 @@ namespace kiwano
void AfterRender() override;
- void HandleMessage(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) override;
+ void HandleMessage(HWND hwnd, UInt32 msg, WPARAM wparam, LPARAM lparam) override;
void UpdateMousePos();
diff --git a/src/kiwano-network/src/HttpClient.cpp b/src/kiwano-network/src/HttpClient.cpp
index e175d539..97f2d66f 100644
--- a/src/kiwano-network/src/HttpClient.cpp
+++ b/src/kiwano-network/src/HttpClient.cpp
@@ -35,10 +35,10 @@ namespace
using namespace kiwano;
using namespace kiwano::network;
- size_t write_data(void* buffer, size_t size, size_t nmemb, void* userp)
+ UInt32 write_data(void* buffer, UInt32 size, UInt32 nmemb, void* userp)
{
kiwano::string* recv_buffer = (kiwano::string*)userp;
- size_t total = size * nmemb;
+ UInt32 total = size * nmemb;
// add data to the end of recv_buffer
// write data maybe called more than once in a single request
@@ -49,7 +49,7 @@ namespace
kiwano::string convert_to_utf8(kiwano::wstring const& str)
{
- std::wstring_convert> utf8_conv;
+ std::wstring_convert> utf8_conv;
kiwano::string result;
try
@@ -66,7 +66,7 @@ namespace
kiwano::wstring convert_from_utf8(kiwano::string const& str)
{
- kiwano::string_convert> utf8_conv;
+ kiwano::string_convert> utf8_conv;
kiwano::wstring result;
try
@@ -256,7 +256,7 @@ namespace kiwano
{
::curl_global_init(CURL_GLOBAL_ALL);
- std::thread thread(bind_func(this, &HttpClient::NetworkThread));
+ std::thread thread(Closure(this, &HttpClient::NetworkThread));
thread.detach();
}
@@ -299,7 +299,7 @@ namespace kiwano
response_queue_.push(response);
response_mutex_.unlock();
- Application::PreformInMainThread(bind_func(this, &HttpClient::DispatchResponseCallback));
+ Application::PreformInMainThread(Closure(this, &HttpClient::DispatchResponseCallback));
}
}
diff --git a/src/kiwano/2d/Actor.cpp b/src/kiwano/2d/Actor.cpp
index 8ef488f5..15518e7a 100644
--- a/src/kiwano/2d/Actor.cpp
+++ b/src/kiwano/2d/Actor.cpp
@@ -27,11 +27,11 @@ namespace kiwano
{
namespace
{
- float default_anchor_x = 0.f;
- float default_anchor_y = 0.f;
+ Float32 default_anchor_x = 0.f;
+ Float32 default_anchor_y = 0.f;
}
- void Actor::SetDefaultAnchor(float anchor_x, float anchor_y)
+ void Actor::SetDefaultAnchor(Float32 anchor_x, Float32 anchor_y)
{
default_anchor_x = anchor_x;
default_anchor_y = anchor_y;
@@ -314,7 +314,7 @@ namespace kiwano
}
}
- void Actor::SetZOrder(int zorder)
+ void Actor::SetZOrder(Int32 zorder)
{
if (z_order_ != zorder)
{
@@ -323,7 +323,7 @@ namespace kiwano
}
}
- void Actor::SetOpacity(float opacity)
+ void Actor::SetOpacity(Float32 opacity)
{
if (opacity_ == opacity)
return;
@@ -341,17 +341,17 @@ namespace kiwano
UpdateOpacity();
}
- void Actor::SetAnchorX(float anchor_x)
+ void Actor::SetAnchorX(Float32 anchor_x)
{
this->SetAnchor(anchor_x, anchor_.y);
}
- void Actor::SetAnchorY(float anchor_y)
+ void Actor::SetAnchorY(Float32 anchor_y)
{
this->SetAnchor(anchor_.x, anchor_y);
}
- void Actor::SetAnchor(float anchor_x, float anchor_y)
+ void Actor::SetAnchor(Float32 anchor_x, Float32 anchor_y)
{
if (anchor_.x == anchor_x && anchor_.y == anchor_y)
return;
@@ -366,12 +366,12 @@ namespace kiwano
this->SetAnchor(anchor.x, anchor.y);
}
- void Actor::SetWidth(float width)
+ void Actor::SetWidth(Float32 width)
{
this->SetSize(width, size_.y);
}
- void Actor::SetHeight(float height)
+ void Actor::SetHeight(Float32 height)
{
this->SetSize(size_.x, height);
}
@@ -381,7 +381,7 @@ namespace kiwano
this->SetSize(size.x, size.y);
}
- void Actor::SetSize(float width, float height)
+ void Actor::SetSize(Float32 width, Float32 height)
{
if (size_.x == width && size_.y == height)
return;
@@ -412,12 +412,12 @@ namespace kiwano
}
}
- void Actor::SetPositionX(float x)
+ void Actor::SetPositionX(Float32 x)
{
this->SetPosition(x, transform_.position.y);
}
- void Actor::SetPositionY(float y)
+ void Actor::SetPositionY(Float32 y)
{
this->SetPosition(transform_.position.x, y);
}
@@ -427,7 +427,7 @@ namespace kiwano
this->SetPosition(p.x, p.y);
}
- void Actor::SetPosition(float x, float y)
+ void Actor::SetPosition(Float32 x, Float32 y)
{
if (transform_.position.x == x && transform_.position.y == y)
return;
@@ -437,7 +437,7 @@ namespace kiwano
dirty_transform_ = true;
}
- void Actor::Move(float x, float y)
+ void Actor::Move(Float32 x, Float32 y)
{
this->SetPosition(transform_.position.x + x, transform_.position.y + y);
}
@@ -447,22 +447,22 @@ namespace kiwano
this->Move(v.x, v.y);
}
- void Actor::SetScaleX(float scale_x)
+ void Actor::SetScaleX(Float32 scale_x)
{
this->SetScale(scale_x, transform_.scale.y);
}
- void Actor::SetScaleY(float scale_y)
+ void Actor::SetScaleY(Float32 scale_y)
{
this->SetScale(transform_.scale.x, scale_y);
}
- void Actor::SetScale(float scale)
+ void Actor::SetScale(Float32 scale)
{
this->SetScale(scale, scale);
}
- void Actor::SetScale(float scale_x, float scale_y)
+ void Actor::SetScale(Float32 scale_x, Float32 scale_y)
{
if (transform_.scale.x == scale_x && transform_.scale.y == scale_y)
return;
@@ -478,17 +478,17 @@ namespace kiwano
this->SetScale(scale.x, scale.y);
}
- void Actor::SetSkewX(float skew_x)
+ void Actor::SetSkewX(Float32 skew_x)
{
this->SetSkew(skew_x, transform_.skew.y);
}
- void Actor::SetSkewY(float skew_y)
+ void Actor::SetSkewY(Float32 skew_y)
{
this->SetSkew(transform_.skew.x, skew_y);
}
- void Actor::SetSkew(float skew_x, float skew_y)
+ void Actor::SetSkew(Float32 skew_x, Float32 skew_y)
{
if (transform_.skew.x == skew_x && transform_.skew.y == skew_y)
return;
@@ -504,7 +504,7 @@ namespace kiwano
this->SetSkew(skew.x, skew.y);
}
- void Actor::SetRotation(float angle)
+ void Actor::SetRotation(Float32 angle)
{
if (transform_.rotation == angle)
return;
@@ -561,7 +561,7 @@ namespace kiwano
Vector Actor::GetChildren(String const& name) const
{
Vector children;
- size_t hash_code = std::hash{}(name);
+ UInt32 hash_code = std::hash{}(name);
for (Actor* child = children_.first_item().get(); child; child = child->next_item().get())
{
@@ -575,7 +575,7 @@ namespace kiwano
ActorPtr Actor::GetChild(String const& name) const
{
- size_t hash_code = std::hash{}(name);
+ UInt32 hash_code = std::hash{}(name);
for (Actor* child = children_.first_item().get(); child; child = child->next_item().get())
{
@@ -627,7 +627,7 @@ namespace kiwano
return;
}
- size_t hash_code = std::hash{}(child_name);
+ UInt32 hash_code = std::hash{}(child_name);
Actor* next;
for (Actor* child = children_.first_item().get(); child; child = next)
diff --git a/src/kiwano/2d/Actor.h b/src/kiwano/2d/Actor.h
index e8764689..ccad06d9 100644
--- a/src/kiwano/2d/Actor.h
+++ b/src/kiwano/2d/Actor.h
@@ -64,55 +64,55 @@ namespace kiwano
bool IsCascadeOpacityEnabled() const { return cascade_opacity_; }
// 获取名称的 Hash 值
- size_t GetHashName() const { return hash_name_; }
+ UInt32 GetHashName() const { return hash_name_; }
// 获取 Z 轴顺序
- int GetZOrder() const { return z_order_; }
+ Int32 GetZOrder() const { return z_order_; }
// 获取坐标
Point GetPosition() const { return transform_.position; }
// 获取 x 坐标
- float GetPositionX() const { return transform_.position.x; }
+ Float32 GetPositionX() const { return transform_.position.x; }
// 获取 y 坐标
- float GetPositionY() const { return transform_.position.y; }
+ Float32 GetPositionY() const { return transform_.position.y; }
// 获取缩放比例
Point GetScale() const { return transform_.scale; }
// 获取横向缩放比例
- float GetScaleX() const { return transform_.scale.x; }
+ Float32 GetScaleX() const { return transform_.scale.x; }
// 获取纵向缩放比例
- float GetScaleY() const { return transform_.scale.y; }
+ Float32 GetScaleY() const { return transform_.scale.y; }
// 获取错切角度
Point GetSkew() const { return transform_.skew; }
// 获取横向错切角度
- float GetSkewX() const { return transform_.skew.x; }
+ Float32 GetSkewX() const { return transform_.skew.x; }
// 获取纵向错切角度
- float GetSkewY() const { return transform_.skew.y; }
+ Float32 GetSkewY() const { return transform_.skew.y; }
// 获取旋转角度
- float GetRotation() const { return transform_.rotation; }
+ Float32 GetRotation() const { return transform_.rotation; }
// 获取宽度
- float GetWidth() const { return size_.x; }
+ Float32 GetWidth() const { return size_.x; }
// 获取高度
- float GetHeight() const { return size_.y; }
+ Float32 GetHeight() const { return size_.y; }
// 获取大小
Size GetSize() const { return size_; }
// 获取缩放后的宽度
- float GetScaledWidth() const { return size_.x * transform_.scale.x; }
+ Float32 GetScaledWidth() const { return size_.x * transform_.scale.x; }
// 获取缩放后的高度
- float GetScaledHeight() const { return size_.y * transform_.scale.y; }
+ Float32 GetScaledHeight() const { return size_.y * transform_.scale.y; }
// 获取缩放后的大小
Size GetScaledSize() const { return Size{ GetScaledWidth(), GetScaledHeight() }; }
@@ -121,16 +121,16 @@ namespace kiwano
Point GetAnchor() const { return anchor_; }
// 获取 x 方向锚点
- float GetAnchorX() const { return anchor_.x; }
+ Float32 GetAnchorX() const { return anchor_.x; }
// 获取 y 方向锚点
- float GetAnchorY() const { return anchor_.y; }
+ Float32 GetAnchorY() const { return anchor_.y; }
// 获取透明度
- float GetOpacity() const { return opacity_; }
+ Float32 GetOpacity() const { return opacity_; }
// 获取显示透明度
- float GetDisplayedOpacity() const { return displayed_opacity_; }
+ Float32 GetDisplayedOpacity() const { return displayed_opacity_; }
// 获取变换
Transform GetTransform() const { return transform_; }
@@ -165,12 +165,12 @@ namespace kiwano
// 设置横坐标
void SetPositionX(
- float x
+ Float32 x
);
// 设置纵坐标
void SetPositionY(
- float y
+ Float32 y
);
// 设置坐标
@@ -180,14 +180,14 @@ namespace kiwano
// 设置坐标
void SetPosition(
- float x,
- float y
+ Float32 x,
+ Float32 y
);
// 移动
void Move(
- float x,
- float y
+ Float32 x,
+ Float32 y
);
// 移动
@@ -198,20 +198,20 @@ namespace kiwano
// 设置横向缩放比例
// 默认为 1.0
void SetScaleX(
- float scale_x
+ Float32 scale_x
);
// 设置纵向缩放比例
// 默认为 1.0
void SetScaleY(
- float scale_y
+ Float32 scale_y
);
// 设置缩放比例
// 默认为 (1.0, 1.0)
void SetScale(
- float scale_x,
- float scale_y
+ Float32 scale_x,
+ Float32 scale_y
);
// 设置缩放比例
@@ -223,26 +223,26 @@ namespace kiwano
// 设置缩放比例
// 默认为 1.0
void SetScale(
- float scale
+ Float32 scale
);
// 设置横向错切角度
// 默认为 0
void SetSkewX(
- float skew_x
+ Float32 skew_x
);
// 设置纵向错切角度
// 默认为 0
void SetSkewY(
- float skew_y
+ Float32 skew_y
);
// 设置错切角度
// 默认为 (0, 0)
void SetSkew(
- float skew_x,
- float skew_y
+ Float32 skew_x,
+ Float32 skew_y
);
// 设置错切角度
@@ -254,26 +254,26 @@ namespace kiwano
// 设置旋转角度
// 默认为 0
void SetRotation(
- float rotation
+ Float32 rotation
);
// 设置锚点的横向位置
// 默认为 0, 范围 [0, 1]
void SetAnchorX(
- float anchor_x
+ Float32 anchor_x
);
// 设置锚点的纵向位置
// 默认为 0, 范围 [0, 1]
void SetAnchorY(
- float anchor_y
+ Float32 anchor_y
);
// 设置锚点位置
// 默认为 (0, 0), 范围 [0, 1]
void SetAnchor(
- float anchor_x,
- float anchor_y
+ Float32 anchor_x,
+ Float32 anchor_y
);
// 设置锚点位置
@@ -284,18 +284,18 @@ namespace kiwano
// 修改宽度
void SetWidth(
- float width
+ Float32 width
);
// 修改高度
void SetHeight(
- float height
+ Float32 height
);
// 修改大小
void SetSize(
- float width,
- float height
+ Float32 width,
+ Float32 height
);
// 修改大小
@@ -311,7 +311,7 @@ namespace kiwano
// 设置透明度
// 默认为 1.0, 范围 [0, 1]
void SetOpacity(
- float opacity
+ Float32 opacity
);
// 启用或禁用级联透明度
@@ -322,7 +322,7 @@ namespace kiwano
// 设置 Z 轴顺序
// 默认为 0
void SetZOrder(
- int zorder
+ Int32 zorder
);
// 是否可响应 (鼠标 Hover | Out | Click 消息)
@@ -403,8 +403,8 @@ namespace kiwano
// 设置默认锚点
static void SetDefaultAnchor(
- float anchor_x,
- float anchor_y
+ Float32 anchor_x,
+ Float32 anchor_y
);
protected:
@@ -432,12 +432,12 @@ namespace kiwano
bool update_pausing_;
bool cascade_opacity_;
bool show_border_;
- int z_order_;
- float opacity_;
- float displayed_opacity_;
+ Int32 z_order_;
+ Float32 opacity_;
+ Float32 displayed_opacity_;
Actor* parent_;
Stage* stage_;
- size_t hash_name_;
+ UInt32 hash_name_;
Point anchor_;
Size size_;
Children children_;
diff --git a/src/kiwano/2d/Canvas.cpp b/src/kiwano/2d/Canvas.cpp
index cef8a6fb..0e2d506f 100644
--- a/src/kiwano/2d/Canvas.cpp
+++ b/src/kiwano/2d/Canvas.cpp
@@ -34,7 +34,7 @@ namespace kiwano
Renderer::GetInstance()->CreateImageRenderTarget(rt_);
}
- Canvas::Canvas(float width, float height)
+ Canvas::Canvas(Float32 width, Float32 height)
: Canvas()
{
this->SetSize(width, height);
@@ -83,7 +83,7 @@ namespace kiwano
fill_color_ = color;
}
- void Canvas::SetStrokeWidth(float width)
+ void Canvas::SetStrokeWidth(Float32 width)
{
stroke_width_ = std::max(width, 0.f);
}
@@ -103,7 +103,7 @@ namespace kiwano
text_style_ = text_style;
}
- void Canvas::SetBrushOpacity(float opacity)
+ void Canvas::SetBrushOpacity(Float32 opacity)
{
rt_.SetOpacity(opacity);
}
@@ -118,12 +118,12 @@ namespace kiwano
return fill_color_;
}
- float Canvas::GetStrokeWidth() const
+ Float32 Canvas::GetStrokeWidth() const
{
return stroke_width_;
}
- float Canvas::GetBrushOpacity() const
+ Float32 Canvas::GetBrushOpacity() const
{
return rt_.GetOpacity();
}
@@ -156,7 +156,7 @@ namespace kiwano
cache_expired_ = true;
}
- void Canvas::DrawCircle(Point const& center, float radius)
+ void Canvas::DrawCircle(Point const& center, Float32 radius)
{
rt_.DrawEllipse(
center,
@@ -203,7 +203,7 @@ namespace kiwano
cache_expired_ = true;
}
- void Canvas::FillCircle(Point const& center, float radius)
+ void Canvas::FillCircle(Point const& center, Float32 radius)
{
rt_.FillEllipse(
center,
@@ -286,7 +286,7 @@ namespace kiwano
geo_sink_.AddBezier(point1, point2, point3);
}
- void Canvas::AddArc(Point const & point, Point const & radius, float rotation, bool clockwise, bool is_small)
+ void Canvas::AddArc(Point const & point, Point const & radius, Float32 rotation, bool clockwise, bool is_small)
{
geo_sink_.AddArc(point, radius, rotation, clockwise, is_small);
}
diff --git a/src/kiwano/2d/Canvas.h b/src/kiwano/2d/Canvas.h
index 6508ebd0..8b636ad0 100644
--- a/src/kiwano/2d/Canvas.h
+++ b/src/kiwano/2d/Canvas.h
@@ -40,8 +40,8 @@ namespace kiwano
);
Canvas(
- float width,
- float height
+ Float32 width,
+ Float32 height
);
virtual ~Canvas();
@@ -61,7 +61,7 @@ namespace kiwano
// 画圆形边框
void DrawCircle(
Point const& center,
- float radius
+ Float32 radius
);
// 画椭圆形边框
@@ -84,7 +84,7 @@ namespace kiwano
// 填充圆形
void FillCircle(
Point const& center,
- float radius
+ Float32 radius
);
// 填充椭圆形
@@ -148,7 +148,7 @@ namespace kiwano
void AddArc(
Point const& point, /* 终点 */
Point const& radius, /* 椭圆半径 */
- float rotation, /* 椭圆旋转角度 */
+ Float32 rotation, /* 椭圆旋转角度 */
bool clockwise = true, /* 顺时针 or 逆时针 */
bool is_small = true /* 是否取小于 180° 的弧 */
);
@@ -179,7 +179,7 @@ namespace kiwano
// 设置线条宽度
void SetStrokeWidth(
- float width
+ Float32 width
);
// 设置线条样式
@@ -199,7 +199,7 @@ namespace kiwano
// 设置画笔透明度
void SetBrushOpacity(
- float opacity
+ Float32 opacity
);
// 获取填充颜色
@@ -209,10 +209,10 @@ namespace kiwano
Color GetStrokeColor() const;
// 获取线条宽度
- float GetStrokeWidth() const;
+ Float32 GetStrokeWidth() const;
// 获取画笔透明度
- float GetBrushOpacity() const;
+ Float32 GetBrushOpacity() const;
// 画笔二维变换
void SetBrushTransform(
@@ -233,7 +233,7 @@ namespace kiwano
void UpdateCache() const;
protected:
- float stroke_width_;
+ Float32 stroke_width_;
Color fill_color_;
Color stroke_color_;
Font text_font_;
diff --git a/src/kiwano/2d/Frame.h b/src/kiwano/2d/Frame.h
index 9f13d4f0..bbe845d2 100644
--- a/src/kiwano/2d/Frame.h
+++ b/src/kiwano/2d/Frame.h
@@ -61,10 +61,10 @@ namespace kiwano
);
// 获取宽度
- float GetWidth() const { return crop_rect_.size.x; }
+ Float32 GetWidth() const { return crop_rect_.size.x; }
// 获取高度
- float GetHeight() const { return crop_rect_.size.y; }
+ Float32 GetHeight() const { return crop_rect_.size.y; }
// 获取大小
Size GetSize() const { return crop_rect_.size; }
diff --git a/src/kiwano/2d/FrameSequence.cpp b/src/kiwano/2d/FrameSequence.cpp
index 4957e1f0..1546fd0a 100644
--- a/src/kiwano/2d/FrameSequence.cpp
+++ b/src/kiwano/2d/FrameSequence.cpp
@@ -59,7 +59,7 @@ namespace kiwano
}
}
- FramePtr FrameSequence::GetFrame(size_t index) const
+ FramePtr FrameSequence::GetFrame(UInt32 index) const
{
KGE_ASSERT(index < frames_.size());
return frames_[index];
diff --git a/src/kiwano/2d/FrameSequence.h b/src/kiwano/2d/FrameSequence.h
index 09c0ccde..582f32cd 100644
--- a/src/kiwano/2d/FrameSequence.h
+++ b/src/kiwano/2d/FrameSequence.h
@@ -47,7 +47,7 @@ namespace kiwano
);
// 获取关键帧
- FramePtr GetFrame(size_t index) const;
+ FramePtr GetFrame(UInt32 index) const;
// 获取关键帧
Vector const& GetFrames() const;
diff --git a/src/kiwano/2d/GifSprite.cpp b/src/kiwano/2d/GifSprite.cpp
index 08c9c471..66eb6fc4 100644
--- a/src/kiwano/2d/GifSprite.cpp
+++ b/src/kiwano/2d/GifSprite.cpp
@@ -73,8 +73,8 @@ namespace kiwano
disposal_type_ = DisposalType::None;
SetSize(
- static_cast(image_.GetWidthInPixels()),
- static_cast(image_.GetHeightInPixels())
+ static_cast(image_.GetWidthInPixels()),
+ static_cast(image_.GetHeightInPixels())
);
if (!frame_rt_.IsValid())
diff --git a/src/kiwano/2d/GifSprite.h b/src/kiwano/2d/GifSprite.h
index 6fec6a03..6a875591 100644
--- a/src/kiwano/2d/GifSprite.h
+++ b/src/kiwano/2d/GifSprite.h
@@ -32,7 +32,7 @@ namespace kiwano
{
public:
using DisposalType = GifImage::DisposalType;
- using LoopDoneCallback = Function;
+ using LoopDoneCallback = Function;
using DoneCallback = Function;
GifSprite();
@@ -62,7 +62,7 @@ namespace kiwano
);
// 设置 GIF 动画循环次数
- inline void SetLoopCount(int loops) { total_loop_count_ = loops; }
+ inline void SetLoopCount(Int32 loops) { total_loop_count_ = loops; }
// 设置 GIF 动画每次循环结束回调函数
inline void SetLoopDoneCallback(LoopDoneCallback const& cb) { loop_cb_ = cb; }
@@ -100,9 +100,9 @@ namespace kiwano
protected:
bool animating_;
- int total_loop_count_;
- int loop_count_;
- UINT next_index_;
+ Int32 total_loop_count_;
+ Int32 loop_count_;
+ UInt32 next_index_;
Duration frame_delay_;
Duration frame_elapsed_;
DisposalType disposal_type_;
diff --git a/src/kiwano/2d/Layer.cpp b/src/kiwano/2d/Layer.cpp
index 2b709eac..a4218f99 100644
--- a/src/kiwano/2d/Layer.cpp
+++ b/src/kiwano/2d/Layer.cpp
@@ -29,7 +29,7 @@ namespace kiwano
{
SetSize(Renderer::GetInstance()->GetOutputSize());
- auto handler = bind_func(this, &Layer::HandleMessages);
+ auto handler = Closure(this, &Layer::HandleMessages);
AddListener(Event::MouseBtnDown, handler);
AddListener(Event::MouseBtnUp, handler);
diff --git a/src/kiwano/2d/Layer.h b/src/kiwano/2d/Layer.h
index 1b48a530..6bcdd43b 100644
--- a/src/kiwano/2d/Layer.h
+++ b/src/kiwano/2d/Layer.h
@@ -31,13 +31,13 @@ namespace kiwano
virtual ~Layer();
- virtual void OnMouseButtonDown(int btn, Point const& p) {}
- virtual void OnMouseButtonUp(int btn, Point const& p) {}
+ virtual void OnMouseButtonDown(Int32 btn, Point const& p) {}
+ virtual void OnMouseButtonUp(Int32 btn, Point const& p) {}
virtual void OnMouseMoved(Point const& p) {}
- virtual void OnMouseWheel(float wheel) {}
+ virtual void OnMouseWheel(Float32 wheel) {}
- virtual void OnKeyDown(int key) {}
- virtual void OnKeyUp(int key) {}
+ virtual void OnKeyDown(Int32 key) {}
+ virtual void OnKeyUp(Int32 key) {}
virtual void OnChar(char c) {}
// 吞没消息
diff --git a/src/kiwano/2d/ShapeActor.cpp b/src/kiwano/2d/ShapeActor.cpp
index cd6963b3..dafeffd0 100644
--- a/src/kiwano/2d/ShapeActor.cpp
+++ b/src/kiwano/2d/ShapeActor.cpp
@@ -68,7 +68,7 @@ namespace kiwano
stroke_color_ = color;
}
- void ShapeActor::SetStrokeWidth(float width)
+ void ShapeActor::SetStrokeWidth(Float32 width)
{
stroke_width_ = std::max(width, 0.f);
}
@@ -201,7 +201,7 @@ namespace kiwano
{
}
- CircleActor::CircleActor(float radius)
+ CircleActor::CircleActor(Float32 radius)
{
SetRadius(radius);
}
@@ -210,7 +210,7 @@ namespace kiwano
{
}
- void CircleActor::SetRadius(float radius)
+ void CircleActor::SetRadius(Float32 radius)
{
geo_ = Geometry::CreateCircle(Point{}, radius);
@@ -287,7 +287,7 @@ namespace kiwano
sink_.AddBezier(point1, point2, point3);
}
- void PathActor::AddArc(Point const& point, Size const& radius, float rotation, bool clockwise, bool is_small)
+ void PathActor::AddArc(Point const& point, Size const& radius, Float32 rotation, bool clockwise, bool is_small)
{
sink_.AddArc(point, radius, rotation, clockwise, is_small);
}
diff --git a/src/kiwano/2d/ShapeActor.h b/src/kiwano/2d/ShapeActor.h
index 7ba2a3c4..d643914d 100644
--- a/src/kiwano/2d/ShapeActor.h
+++ b/src/kiwano/2d/ShapeActor.h
@@ -44,7 +44,7 @@ namespace kiwano
Color GetStrokeColor() const { return stroke_color_; }
// 获取线条宽度
- float GetStrokeWidth() const { return stroke_width_; }
+ Float32 GetStrokeWidth() const { return stroke_width_; }
// 获取线条样式
StrokeStyle SetStrokeStyle() const { return stroke_style_; }
@@ -67,7 +67,7 @@ namespace kiwano
// 设置线条宽度
void SetStrokeWidth(
- float width
+ Float32 width
);
// 设置线条样式
@@ -86,7 +86,7 @@ namespace kiwano
protected:
Color fill_color_;
Color stroke_color_;
- float stroke_width_;
+ Float32 stroke_width_;
StrokeStyle stroke_style_;
Geometry geo_;
};
@@ -183,17 +183,17 @@ namespace kiwano
CircleActor();
CircleActor(
- float radius
+ Float32 radius
);
virtual ~CircleActor();
- inline float GetRadius() const { return radius_; }
+ inline Float32 GetRadius() const { return radius_; }
- void SetRadius(float radius);
+ void SetRadius(Float32 radius);
protected:
- float radius_;
+ Float32 radius_;
};
@@ -261,7 +261,7 @@ namespace kiwano
void AddArc(
Point const& point, /* 终点 */
Size const& radius, /* 椭圆半径 */
- float rotation, /* 椭圆旋转角度 */
+ Float32 rotation, /* 椭圆旋转角度 */
bool clockwise = true, /* 顺时针 or 逆时针 */
bool is_small = true /* 是否取小于 180° 的弧 */
);
diff --git a/src/kiwano/2d/Text.cpp b/src/kiwano/2d/Text.cpp
index dc460d0b..2a9c814d 100644
--- a/src/kiwano/2d/Text.cpp
+++ b/src/kiwano/2d/Text.cpp
@@ -68,6 +68,7 @@ namespace kiwano
, style_(style)
, text_(text)
, layout_dirty_(true)
+ , format_dirty_(true)
{
}
@@ -102,7 +103,7 @@ namespace kiwano
}
}
- void Text::SetFontSize(float size)
+ void Text::SetFontSize(Float32 size)
{
if (font_.size != size)
{
@@ -111,7 +112,7 @@ namespace kiwano
}
}
- void Text::SetFontWeight(unsigned int weight)
+ void Text::SetFontWeight(UInt32 weight)
{
if (font_.weight != weight)
{
@@ -134,7 +135,7 @@ namespace kiwano
}
}
- void Text::SetWrapWidth(float wrap_width)
+ void Text::SetWrapWidth(Float32 wrap_width)
{
if (style_.wrap_width != wrap_width)
{
@@ -143,7 +144,7 @@ namespace kiwano
}
}
- void Text::SetLineSpacing(float line_spacing)
+ void Text::SetLineSpacing(Float32 line_spacing)
{
if (style_.line_spacing != line_spacing)
{
@@ -189,7 +190,7 @@ namespace kiwano
style_.outline_color = outline_color;
}
- void Text::SetOutlineWidth(float outline_width)
+ void Text::SetOutlineWidth(Float32 outline_width)
{
style_.outline_width = outline_width;
}
diff --git a/src/kiwano/2d/Text.h b/src/kiwano/2d/Text.h
index 1877b711..ddc48b17 100644
--- a/src/kiwano/2d/Text.h
+++ b/src/kiwano/2d/Text.h
@@ -87,12 +87,12 @@ namespace kiwano
// 设置字号(默认值为 18)
void SetFontSize(
- float size
+ Float32 size
);
// 设置字体粗细值(默认值为 FontWeight::Normal)
void SetFontWeight(
- unsigned int weight
+ UInt32 weight
);
// 设置文字颜色(默认值为 Color::White)
@@ -107,12 +107,12 @@ namespace kiwano
// 设置文本自动换行的宽度(默认为 0)
void SetWrapWidth(
- float wrap_width
+ Float32 wrap_width
);
// 设置行间距(默认为 0)
void SetLineSpacing(
- float line_spacing
+ Float32 line_spacing
);
// 设置对齐方式(默认为 TextAlign::Left)
@@ -142,7 +142,7 @@ namespace kiwano
// 设置描边线宽
void SetOutlineWidth(
- float outline_width
+ Float32 outline_width
);
// 设置描边线相交样式
diff --git a/src/kiwano/2d/TextStyle.hpp b/src/kiwano/2d/TextStyle.hpp
index 1e5a299d..b11c4c61 100644
--- a/src/kiwano/2d/TextStyle.hpp
+++ b/src/kiwano/2d/TextStyle.hpp
@@ -37,13 +37,13 @@ namespace kiwano
public:
Color color; // 颜色
TextAlign alignment; // 对齐方式
- float wrap_width; // 自动换行宽度
- float line_spacing; // 行间距
+ Float32 wrap_width; // 自动换行宽度
+ Float32 line_spacing; // 行间距
bool underline; // 下划线
bool strikethrough; // 删除线
bool outline; // 显示描边
Color outline_color; // 描边颜色
- float outline_width; // 描边线宽
+ Float32 outline_width; // 描边线宽
StrokeStyle outline_stroke; // 描边线相交样式
public:
@@ -63,13 +63,13 @@ namespace kiwano
TextStyle(
Color color,
TextAlign alignment = TextAlign::Left,
- float wrap_width = 0.f,
- float line_spacing = 0.f,
+ Float32 wrap_width = 0.f,
+ Float32 line_spacing = 0.f,
bool underline = false,
bool strikethrough = false,
bool outline = true,
Color outline_color = Color(Color::Black, 0.5),
- float outline_width = 1.f,
+ Float32 outline_width = 1.f,
StrokeStyle outline_stroke = StrokeStyle::Round
)
: color(color)
diff --git a/src/kiwano/2d/Transform.hpp b/src/kiwano/2d/Transform.hpp
index db928c97..64c8824e 100644
--- a/src/kiwano/2d/Transform.hpp
+++ b/src/kiwano/2d/Transform.hpp
@@ -26,7 +26,7 @@ namespace kiwano
class Transform
{
public:
- float rotation; // 旋转
+ Float32 rotation; // 旋转
Point position; // 坐标
Point scale; // 缩放
Point skew; // 错切角度
diff --git a/src/kiwano/2d/Transition.cpp b/src/kiwano/2d/Transition.cpp
index 8fe41b9c..dfa6dd2f 100644
--- a/src/kiwano/2d/Transition.cpp
+++ b/src/kiwano/2d/Transition.cpp
@@ -235,9 +235,9 @@ namespace kiwano
// MoveTransition
//-------------------------------------------------------
- MoveTransition::MoveTransition(Duration duration, Direction direction)
+ MoveTransition::MoveTransition(Duration duration, Type type)
: Transition(duration)
- , direction_(direction)
+ , type_(type)
{
}
@@ -245,21 +245,21 @@ namespace kiwano
{
Transition::Init(prev, next);
- switch (direction_)
+ switch (type_)
{
- case Direction::Up:
+ case Type::Up:
pos_delta_ = Point(0, -window_size_.y);
start_pos_ = Point(0, window_size_.y);
break;
- case Direction::Down:
+ case Type::Down:
pos_delta_ = Point(0, window_size_.y);
start_pos_ = Point(0, -window_size_.y);
break;
- case Direction::Left:
+ case Type::Left:
pos_delta_ = Point(-window_size_.x, 0);
start_pos_ = Point(window_size_.x, 0);
break;
- case Direction::Right:
+ case Type::Right:
pos_delta_ = Point(window_size_.x, 0);
start_pos_ = Point(-window_size_.x, 0);
break;
@@ -314,7 +314,7 @@ namespace kiwano
// RotationTransition
//-------------------------------------------------------
- RotationTransition::RotationTransition(Duration duration, float rotation)
+ RotationTransition::RotationTransition(Duration duration, Float32 rotation)
: Transition(duration)
, rotation_(rotation)
{
diff --git a/src/kiwano/2d/Transition.h b/src/kiwano/2d/Transition.h
index a70b89cd..af0a0fe9 100644
--- a/src/kiwano/2d/Transition.h
+++ b/src/kiwano/2d/Transition.h
@@ -58,7 +58,7 @@ namespace kiwano
protected:
bool done_;
- float process_;
+ Float32 process_;
Duration duration_;
Duration delta_;
Size window_size_;
@@ -132,9 +132,17 @@ namespace kiwano
: public Transition
{
public:
+ enum class Type : Int32
+ {
+ Up, /* 上移 */
+ Down, /* 下移 */
+ Left, /* 左移 */
+ Right /* 右移 */
+ };
+
explicit MoveTransition(
- Duration moveDuration, /* 动画持续时长 */
- Direction direction /* 移动方向 */
+ Duration duration, /* 动画持续时长 */
+ Type type /* 移动方式 */
);
protected:
@@ -148,9 +156,9 @@ namespace kiwano
void Reset() override;
protected:
- Direction direction_;
- Point pos_delta_;
- Point start_pos_;
+ Type type_;
+ Point pos_delta_;
+ Point start_pos_;
};
@@ -160,8 +168,8 @@ namespace kiwano
{
public:
explicit RotationTransition(
- Duration moveDuration, /* 动画持续时长 */
- float rotation = 360 /* 旋转度数 */
+ Duration duration, /* 动画持续时长 */
+ Float32 rotation = 360 /* 旋转度数 */
);
protected:
@@ -175,6 +183,6 @@ namespace kiwano
void Reset() override;
protected:
- float rotation_;
+ Float32 rotation_;
};
}
diff --git a/src/kiwano/2d/action/Action.h b/src/kiwano/2d/action/Action.h
index ce7eb0c2..6becb2e3 100644
--- a/src/kiwano/2d/action/Action.h
+++ b/src/kiwano/2d/action/Action.h
@@ -62,7 +62,7 @@ namespace kiwano
inline void SetDelay(Duration delay) { delay_ = delay; }
// 设置循环次数 (-1 为永久循环)
- inline void SetLoops(int loops) { loops_ = loops; }
+ inline void SetLoops(Int32 loops) { loops_ = loops; }
// 动作结束时移除目标角色
inline void RemoveTargetWhenDone() { detach_target_ = true; }
@@ -89,7 +89,7 @@ namespace kiwano
inline bool IsRemoveable() const { return status_ == Status::Removeable; }
- inline int GetLoops() const { return loops_; }
+ inline Int32 GetLoops() const { return loops_; }
inline Duration GetDelay() const { return delay_; }
@@ -114,8 +114,8 @@ namespace kiwano
Status status_;
bool running_;
bool detach_target_;
- int loops_;
- int loops_done_;
+ Int32 loops_;
+ Int32 loops_done_;
Duration delay_;
Duration elapsed_;
ActionCallback cb_done_;
diff --git a/src/kiwano/2d/action/ActionHelper.h b/src/kiwano/2d/action/ActionHelper.h
index c8d396f3..b44bfd41 100644
--- a/src/kiwano/2d/action/ActionHelper.h
+++ b/src/kiwano/2d/action/ActionHelper.h
@@ -30,7 +30,7 @@ namespace kiwano
struct ActionHelper
{
// 设置循环次数
- inline ActionHelper& SetLoops(int loops) { base->SetLoops(loops); return (*this); }
+ inline ActionHelper& SetLoops(Int32 loops) { base->SetLoops(loops); return (*this); }
// 设置动作延迟
inline ActionHelper& SetDelay(Duration delay) { base->SetDelay(delay); return (*this); }
@@ -64,7 +64,7 @@ namespace kiwano
inline TweenHelper& SetDuration(Duration dur) { base->SetDuration(dur); return (*this); }
// 设置循环次数
- inline TweenHelper& SetLoops(int loops) { base->SetLoops(loops); return (*this); }
+ inline TweenHelper& SetLoops(Int32 loops) { base->SetLoops(loops); return (*this); }
// 设置缓动函数
inline TweenHelper& SetEaseFunc(EaseFunc ease) { base->SetEaseFunc(ease); return (*this); }
@@ -117,8 +117,8 @@ namespace kiwano
JumpBy(
Duration dur,
Point const& pos, /* 目的坐标 */
- float height, /* 跳跃高度 */
- int jumps = 1) /* 跳跃次数 */
+ Float32 height, /* 跳跃高度 */
+ Int32 jumps = 1) /* 跳跃次数 */
{
return TweenHelper(new kiwano::ActionJumpBy(dur, pos, height, jumps));
}
@@ -127,38 +127,38 @@ namespace kiwano
JumpTo(
Duration dur,
Point const& pos, /* 目的坐标 */
- float height, /* 跳跃高度 */
- int jumps = 1) /* 跳跃次数 */
+ Float32 height, /* 跳跃高度 */
+ Int32 jumps = 1) /* 跳跃次数 */
{
return TweenHelper(new kiwano::ActionJumpTo(dur, pos, height, jumps));
}
static inline TweenHelper
- ScaleBy(Duration dur, float scale)
+ ScaleBy(Duration dur, Float32 scale)
{
return TweenHelper(new kiwano::ActionScaleBy(dur, scale));
}
static inline TweenHelper
- ScaleBy(Duration dur, float scale_x, float scale_y)
+ ScaleBy(Duration dur, Float32 scale_x, Float32 scale_y)
{
return TweenHelper(new kiwano::ActionScaleBy(dur, scale_x, scale_y));
}
static inline TweenHelper
- ScaleTo(Duration dur, float scale)
+ ScaleTo(Duration dur, Float32 scale)
{
return TweenHelper(new kiwano::ActionScaleTo(dur, scale));
}
static inline TweenHelper
- ScaleTo(Duration dur, float scale_x, float scale_y)
+ ScaleTo(Duration dur, Float32 scale_x, Float32 scale_y)
{
return TweenHelper(new kiwano::ActionScaleTo(dur, scale_x, scale_y));
}
static inline TweenHelper
- FadeTo(Duration dur, float opacity)
+ FadeTo(Duration dur, Float32 opacity)
{
return TweenHelper(new kiwano::ActionFadeTo(dur, opacity));
}
@@ -176,13 +176,13 @@ namespace kiwano
}
static inline TweenHelper
- RotateBy(Duration dur, float rotation)
+ RotateBy(Duration dur, Float32 rotation)
{
return TweenHelper(new kiwano::ActionRotateBy(dur, rotation));
}
static inline TweenHelper
- RotateTo(Duration dur, float rotation)
+ RotateTo(Duration dur, Float32 rotation)
{
return TweenHelper(new kiwano::ActionRotateTo(dur, rotation));
}
@@ -192,8 +192,8 @@ namespace kiwano
Duration duration, /* 持续时长 */
Geometry const& geo, /* 路线 */
bool rotating = false, /* 沿路线切线方向旋转 */
- float start = 0.f, /* 起点 */
- float end = 1.f, /* 终点 */
+ Float32 start = 0.f, /* 起点 */
+ Float32 end = 1.f, /* 终点 */
EaseFunc func = nullptr /* 速度变化 */
)
{
@@ -205,8 +205,8 @@ namespace kiwano
Duration duration, /* 持续时长 */
GeometrySink& sink, /* 路线生成器 */
bool rotating = false, /* 沿路线切线方向旋转 */
- float start = 0.f, /* 起点 */
- float end = 1.f, /* 终点 */
+ Float32 start = 0.f, /* 起点 */
+ Float32 end = 1.f, /* 终点 */
EaseFunc func = nullptr /* 速度变化 */
)
{
@@ -248,7 +248,7 @@ namespace kiwano
KGE_DEPRECATED("Tween::OpacityBy has been removed, use Tween::FadeTo instead")
static inline TweenHelper
- OpacityBy(float opacity)
+ OpacityBy(Float32 opacity)
{
KGE_ASSERT("Tween::OpacityBy has been removed, use Tween::FadeTo instead");
return TweenHelper(nullptr);
@@ -256,7 +256,7 @@ namespace kiwano
KGE_DEPRECATED("Tween::OpacityTo is deprecated, use Tween::FadeTo instead")
static inline TweenHelper
- OpacityTo(Duration dur, float opacity)
+ OpacityTo(Duration dur, Float32 opacity)
{
return TweenHelper(new kiwano::ActionFadeTo(dur, opacity));
}
diff --git a/src/kiwano/2d/action/ActionManager.cpp b/src/kiwano/2d/action/ActionManager.cpp
index 2a0c5ac5..186c717f 100644
--- a/src/kiwano/2d/action/ActionManager.cpp
+++ b/src/kiwano/2d/action/ActionManager.cpp
@@ -42,7 +42,7 @@ namespace kiwano
}
}
- ActionPtr ActionManager::AddAction(ActionPtr action)
+ Action* ActionManager::AddAction(ActionPtr action)
{
KGE_ASSERT(action && "AddAction failed, NULL pointer exception");
@@ -50,7 +50,7 @@ namespace kiwano
{
actions_.push_back_item(action);
}
- return action;
+ return action.get();
}
ActionPtr ActionManager::GetAction(String const & name)
diff --git a/src/kiwano/2d/action/ActionManager.h b/src/kiwano/2d/action/ActionManager.h
index 27e3c092..36ea6b10 100644
--- a/src/kiwano/2d/action/ActionManager.h
+++ b/src/kiwano/2d/action/ActionManager.h
@@ -29,7 +29,7 @@ namespace kiwano
public:
// 添加动作
- ActionPtr AddAction(
+ Action* AddAction(
ActionPtr action
);
diff --git a/src/kiwano/2d/action/ActionTween.cpp b/src/kiwano/2d/action/ActionTween.cpp
index b78c8720..360f507a 100644
--- a/src/kiwano/2d/action/ActionTween.cpp
+++ b/src/kiwano/2d/action/ActionTween.cpp
@@ -27,12 +27,12 @@ namespace kiwano
// Ease Functions
//-------------------------------------------------------
- inline EaseFunc MakeEaseIn(float rate) { return std::bind(math::EaseIn, std::placeholders::_1, rate); }
- inline EaseFunc MakeEaseOut(float rate) { return std::bind(math::EaseOut, std::placeholders::_1, rate); }
- inline EaseFunc MakeEaseInOut(float rate) { return std::bind(math::EaseInOut, std::placeholders::_1, rate); }
- inline EaseFunc MakeEaseElasticIn(float period) { return std::bind(math::EaseElasticIn, std::placeholders::_1, period); }
- inline EaseFunc MakeEaseElasticOut(float period) { return std::bind(math::EaseElasticOut, std::placeholders::_1, period); }
- inline EaseFunc MakeEaseElasticInOut(float period) { return std::bind(math::EaseElasticInOut, std::placeholders::_1, period); }
+ inline EaseFunc MakeEaseIn(Float32 rate) { return std::bind(math::EaseIn, std::placeholders::_1, rate); }
+ inline EaseFunc MakeEaseOut(Float32 rate) { return std::bind(math::EaseOut, std::placeholders::_1, rate); }
+ inline EaseFunc MakeEaseInOut(Float32 rate) { return std::bind(math::EaseInOut, std::placeholders::_1, rate); }
+ inline EaseFunc MakeEaseElasticIn(Float32 period) { return std::bind(math::EaseElasticIn, std::placeholders::_1, period); }
+ inline EaseFunc MakeEaseElasticOut(Float32 period) { return std::bind(math::EaseElasticOut, std::placeholders::_1, period); }
+ inline EaseFunc MakeEaseElasticInOut(Float32 period) { return std::bind(math::EaseElasticInOut, std::placeholders::_1, period); }
KGE_API EaseFunc Ease::Linear = math::Linear;
KGE_API EaseFunc Ease::EaseIn = MakeEaseIn(2.f);
@@ -99,7 +99,7 @@ namespace kiwano
void ActionTween::Update(ActorPtr target, Duration dt)
{
- float percent;
+ Float32 percent;
if (dur_.IsZero())
{
@@ -109,14 +109,14 @@ namespace kiwano
else
{
Duration elapsed = elapsed_ - delay_;
- float loops_done = elapsed / dur_;
+ Float32 loops_done = elapsed / dur_;
- while (loops_done_ < static_cast(loops_done))
+ while (loops_done_ < static_cast(loops_done))
{
Complete(target); // loops_done_++
}
- percent = (status_ == Status::Done) ? 1.f : (loops_done - static_cast(loops_done_));
+ percent = (status_ == Status::Done) ? 1.f : (loops_done - static_cast(loops_done_));
}
if (ease_func_)
@@ -149,7 +149,7 @@ namespace kiwano
}
}
- void ActionMoveBy::UpdateTween(ActorPtr target, float percent)
+ void ActionMoveBy::UpdateTween(ActorPtr target, Float32 percent)
{
Point diff = target->GetPosition() - prev_pos_;
start_pos_ = start_pos_ + diff;
@@ -192,7 +192,7 @@ namespace kiwano
// Jump Action
//-------------------------------------------------------
- ActionJumpBy::ActionJumpBy(Duration duration, Point const& vec, float height, int jumps, EaseFunc func)
+ ActionJumpBy::ActionJumpBy(Duration duration, Point const& vec, Float32 height, Int32 jumps, EaseFunc func)
: ActionTween(duration, func)
, delta_pos_(vec)
, height_(height)
@@ -218,11 +218,11 @@ namespace kiwano
}
}
- void ActionJumpBy::UpdateTween(ActorPtr target, float percent)
+ void ActionJumpBy::UpdateTween(ActorPtr target, Float32 percent)
{
- float frac = fmod(percent * jumps_, 1.f);
- float x = delta_pos_.x * percent;
- float y = height_ * 4 * frac * (1 - frac);
+ Float32 frac = fmod(percent * jumps_, 1.f);
+ Float32 x = delta_pos_.x * percent;
+ Float32 y = height_ * 4 * frac * (1 - frac);
y += delta_pos_.y * percent;
Point diff = target->GetPosition() - prev_pos_;
@@ -234,7 +234,7 @@ namespace kiwano
prev_pos_ = new_pos;
}
- ActionJumpTo::ActionJumpTo(Duration duration, Point const& pos, float height, int jumps, EaseFunc func)
+ ActionJumpTo::ActionJumpTo(Duration duration, Point const& pos, Float32 height, Int32 jumps, EaseFunc func)
: ActionJumpBy(duration, Point(), height, jumps, func)
, end_pos_(pos)
{
@@ -256,12 +256,12 @@ namespace kiwano
// Scale Action
//-------------------------------------------------------
- ActionScaleBy::ActionScaleBy(Duration duration, float scale, EaseFunc func)
+ ActionScaleBy::ActionScaleBy(Duration duration, Float32 scale, EaseFunc func)
: ActionScaleBy(duration, scale, scale, func)
{
}
- ActionScaleBy::ActionScaleBy(Duration duration, float scale_x, float scale_y, EaseFunc func)
+ ActionScaleBy::ActionScaleBy(Duration duration, Float32 scale_x, Float32 scale_y, EaseFunc func)
: ActionTween(duration, func)
, delta_x_(scale_x)
, delta_y_(scale_y)
@@ -279,7 +279,7 @@ namespace kiwano
}
}
- void ActionScaleBy::UpdateTween(ActorPtr target, float percent)
+ void ActionScaleBy::UpdateTween(ActorPtr target, Float32 percent)
{
target->SetScale(start_scale_x_ + delta_x_ * percent, start_scale_y_ + delta_y_ * percent);
}
@@ -294,14 +294,14 @@ namespace kiwano
return new (std::nothrow) ActionScaleBy(dur_, -delta_x_, -delta_y_, ease_func_);
}
- ActionScaleTo::ActionScaleTo(Duration duration, float scale, EaseFunc func)
+ ActionScaleTo::ActionScaleTo(Duration duration, Float32 scale, EaseFunc func)
: ActionScaleBy(duration, 0, 0, func)
{
end_scale_x_ = scale;
end_scale_y_ = scale;
}
- ActionScaleTo::ActionScaleTo(Duration duration, float scale_x, float scale_y, EaseFunc func)
+ ActionScaleTo::ActionScaleTo(Duration duration, Float32 scale_x, Float32 scale_y, EaseFunc func)
: ActionScaleBy(duration, 0, 0, func)
{
end_scale_x_ = scale_x;
@@ -325,7 +325,7 @@ namespace kiwano
// Opacity Action
//-------------------------------------------------------
- ActionFadeTo::ActionFadeTo(Duration duration, float opacity, EaseFunc func)
+ ActionFadeTo::ActionFadeTo(Duration duration, Float32 opacity, EaseFunc func)
: ActionTween(duration, func)
, delta_val_(0.f)
, start_val_(0.f)
@@ -342,7 +342,7 @@ namespace kiwano
}
}
- void ActionFadeTo::UpdateTween(ActorPtr target, float percent)
+ void ActionFadeTo::UpdateTween(ActorPtr target, Float32 percent)
{
target->SetOpacity(start_val_ + delta_val_ * percent);
}
@@ -367,7 +367,7 @@ namespace kiwano
// Rotate Action
//-------------------------------------------------------
- ActionRotateBy::ActionRotateBy(Duration duration, float rotation, EaseFunc func)
+ ActionRotateBy::ActionRotateBy(Duration duration, Float32 rotation, EaseFunc func)
: ActionTween(duration, func)
, start_val_()
, delta_val_(rotation)
@@ -382,9 +382,9 @@ namespace kiwano
}
}
- void ActionRotateBy::UpdateTween(ActorPtr target, float percent)
+ void ActionRotateBy::UpdateTween(ActorPtr target, Float32 percent)
{
- float rotation = start_val_ + delta_val_ * percent;
+ Float32 rotation = start_val_ + delta_val_ * percent;
if (rotation > 360.f)
rotation -= 360.f;
@@ -401,7 +401,7 @@ namespace kiwano
return new (std::nothrow) ActionRotateBy(dur_, -delta_val_, ease_func_);
}
- ActionRotateTo::ActionRotateTo(Duration duration, float rotation, EaseFunc func)
+ ActionRotateTo::ActionRotateTo(Duration duration, Float32 rotation, EaseFunc func)
: ActionRotateBy(duration, 0, func)
{
end_val_ = rotation;
@@ -440,7 +440,7 @@ namespace kiwano
this->Done();
}
- void ActionCustom::UpdateTween(ActorPtr target, float percent)
+ void ActionCustom::UpdateTween(ActorPtr target, Float32 percent)
{
if (tween_func_)
tween_func_(target, percent);
diff --git a/src/kiwano/2d/action/ActionTween.h b/src/kiwano/2d/action/ActionTween.h
index bb4d3b56..4b52f091 100644
--- a/src/kiwano/2d/action/ActionTween.h
+++ b/src/kiwano/2d/action/ActionTween.h
@@ -25,7 +25,7 @@
namespace kiwano
{
// 缓动函数
- using EaseFunc = Function;
+ using EaseFunc = Function;
// 缓动函数枚举
// See https://easings.net for more information
@@ -91,7 +91,7 @@ namespace kiwano
protected:
void Update(ActorPtr target, Duration dt) override;
- virtual void UpdateTween(ActorPtr target, float percent) = 0;
+ virtual void UpdateTween(ActorPtr target, Float32 percent) = 0;
protected:
Duration dur_;
@@ -119,7 +119,7 @@ namespace kiwano
protected:
void Init(ActorPtr target) override;
- void UpdateTween(ActorPtr target, float percent) override;
+ void UpdateTween(ActorPtr target, Float32 percent) override;
protected:
Point start_pos_;
@@ -165,8 +165,8 @@ namespace kiwano
ActionJumpBy(
Duration duration, /* 持续时长 */
Point const& vec, /* 跳跃距离 */
- float height, /* 跳跃高度 */
- int jumps = 1, /* 跳跃次数 */
+ Float32 height, /* 跳跃高度 */
+ Int32 jumps = 1, /* 跳跃次数 */
EaseFunc func = nullptr /* 速度变化 */
);
@@ -179,13 +179,13 @@ namespace kiwano
protected:
void Init(ActorPtr target) override;
- void UpdateTween(ActorPtr target, float percent) override;
+ void UpdateTween(ActorPtr target, Float32 percent) override;
protected:
Point start_pos_;
Point delta_pos_;
- float height_;
- int jumps_;
+ Float32 height_;
+ Int32 jumps_;
Point prev_pos_;
};
@@ -198,8 +198,8 @@ namespace kiwano
ActionJumpTo(
Duration duration, /* 持续时长 */
Point const& pos, /* 目的坐标 */
- float height, /* 跳跃高度 */
- int jumps = 1, /* 跳跃次数 */
+ Float32 height, /* 跳跃高度 */
+ Int32 jumps = 1, /* 跳跃次数 */
EaseFunc func = nullptr /* 速度变化 */
);
@@ -228,14 +228,14 @@ namespace kiwano
public:
ActionScaleBy(
Duration duration, /* 持续时长 */
- float scale, /* 相对变化值 */
+ Float32 scale, /* 相对变化值 */
EaseFunc func = nullptr /* 速度变化 */
);
ActionScaleBy(
Duration duration, /* 持续时长 */
- float scale_x, /* 横向缩放相对变化值 */
- float scale_y, /* 纵向缩放相对变化值 */
+ Float32 scale_x, /* 横向缩放相对变化值 */
+ Float32 scale_y, /* 纵向缩放相对变化值 */
EaseFunc func = nullptr /* 速度变化 */
);
@@ -248,13 +248,13 @@ namespace kiwano
protected:
void Init(ActorPtr target) override;
- void UpdateTween(ActorPtr target, float percent) override;
+ void UpdateTween(ActorPtr target, Float32 percent) override;
protected:
- float start_scale_x_;
- float start_scale_y_;
- float delta_x_;
- float delta_y_;
+ Float32 start_scale_x_;
+ Float32 start_scale_y_;
+ Float32 delta_x_;
+ Float32 delta_y_;
};
@@ -265,14 +265,14 @@ namespace kiwano
public:
ActionScaleTo(
Duration duration, /* 持续时长 */
- float scale, /* 目标值 */
+ Float32 scale, /* 目标值 */
EaseFunc func = nullptr /* 速度变化 */
);
ActionScaleTo(
Duration duration, /* 持续时长 */
- float scale_x, /* 横向缩放目标值 */
- float scale_y, /* 纵向缩放目标值 */
+ Float32 scale_x, /* 横向缩放目标值 */
+ Float32 scale_y, /* 纵向缩放目标值 */
EaseFunc func = nullptr /* 速度变化 */
);
@@ -290,8 +290,8 @@ namespace kiwano
void Init(ActorPtr target) override;
protected:
- float end_scale_x_;
- float end_scale_y_;
+ Float32 end_scale_x_;
+ Float32 end_scale_y_;
};
@@ -302,7 +302,7 @@ namespace kiwano
public:
ActionFadeTo(
Duration duration, /* 持续时长 */
- float opacity, /* 目标值 */
+ Float32 opacity, /* 目标值 */
EaseFunc func = nullptr /* 速度变化 */
);
@@ -319,12 +319,12 @@ namespace kiwano
protected:
void Init(ActorPtr target) override;
- void UpdateTween(ActorPtr target, float percent) override;
+ void UpdateTween(ActorPtr target, Float32 percent) override;
protected:
- float start_val_;
- float delta_val_;
- float end_val_;
+ Float32 start_val_;
+ Float32 delta_val_;
+ Float32 end_val_;
};
@@ -361,7 +361,7 @@ namespace kiwano
public:
ActionRotateBy(
Duration duration, /* 持续时长 */
- float rotation, /* 相对变化值 */
+ Float32 rotation, /* 相对变化值 */
EaseFunc func = nullptr /* 速度变化 */
);
@@ -374,11 +374,11 @@ namespace kiwano
protected:
void Init(ActorPtr target) override;
- void UpdateTween(ActorPtr target, float percent) override;
+ void UpdateTween(ActorPtr target, Float32 percent) override;
protected:
- float start_val_;
- float delta_val_;
+ Float32 start_val_;
+ Float32 delta_val_;
};
@@ -389,7 +389,7 @@ namespace kiwano
public:
ActionRotateTo(
Duration duration, /* 持续时长 */
- float rotation, /* 目标值 */
+ Float32 rotation, /* 目标值 */
EaseFunc func = nullptr /* 速度变化 */
);
@@ -407,7 +407,7 @@ namespace kiwano
void Init(ActorPtr target) override;
protected:
- float end_val_;
+ Float32 end_val_;
};
@@ -416,7 +416,7 @@ namespace kiwano
: public ActionTween
{
public:
- using TweenFunc = Function;
+ using TweenFunc = Function;
ActionCustom(
Duration duration, /* 持续时长 */
@@ -437,7 +437,7 @@ namespace kiwano
protected:
void Init(ActorPtr target) override;
- void UpdateTween(ActorPtr target, float percent) override;
+ void UpdateTween(ActorPtr target, Float32 percent) override;
protected:
TweenFunc tween_func_;
diff --git a/src/kiwano/2d/action/ActionWalk.cpp b/src/kiwano/2d/action/ActionWalk.cpp
index 3a4c77aa..c6153ce5 100644
--- a/src/kiwano/2d/action/ActionWalk.cpp
+++ b/src/kiwano/2d/action/ActionWalk.cpp
@@ -23,7 +23,7 @@
namespace kiwano
{
- ActionWalk::ActionWalk(Duration duration, bool rotating, float start, float end, EaseFunc func)
+ ActionWalk::ActionWalk(Duration duration, bool rotating, Float32 start, Float32 end, EaseFunc func)
: ActionTween(duration, func)
, start_(start)
, end_(end)
@@ -32,7 +32,7 @@ namespace kiwano
{
}
- ActionWalk::ActionWalk(Duration duration, Geometry const& path, bool rotating, float start, float end, EaseFunc func)
+ ActionWalk::ActionWalk(Duration duration, Geometry const& path, bool rotating, Float32 start, Float32 end, EaseFunc func)
: ActionWalk(duration, rotating, start, end, func)
{
path_ = path;
@@ -70,9 +70,9 @@ namespace kiwano
length_ = path_.GetLength();
}
- void ActionWalk::UpdateTween(ActorPtr target, float percent)
+ void ActionWalk::UpdateTween(ActorPtr target, Float32 percent)
{
- float distance = length_ * std::min(std::max((end_ - start_) * percent + start_, 0.f), 1.f);
+ Float32 distance = length_ * std::min(std::max((end_ - start_) * percent + start_, 0.f), 1.f);
Point point, tangent;
if (path_.ComputePointAtLength(distance, point, tangent))
@@ -81,8 +81,8 @@ namespace kiwano
if (rotating_)
{
- float ac = math::Acos(tangent.x);
- float rotation = (tangent.y < 0.f) ? 360.f - ac : ac;
+ Float32 ac = math::Acos(tangent.x);
+ Float32 rotation = (tangent.y < 0.f) ? 360.f - ac : ac;
target->SetRotation(rotation);
}
}
@@ -114,7 +114,7 @@ namespace kiwano
sink_.AddBezier(point1, point2, point3);
}
- void ActionWalk::AddArc(Point const& point, Size const& radius, float rotation, bool clockwise, bool is_small)
+ void ActionWalk::AddArc(Point const& point, Size const& radius, Float32 rotation, bool clockwise, bool is_small)
{
sink_.AddArc(point, radius, rotation, clockwise, is_small);
}
diff --git a/src/kiwano/2d/action/ActionWalk.h b/src/kiwano/2d/action/ActionWalk.h
index f9747556..9d05c893 100644
--- a/src/kiwano/2d/action/ActionWalk.h
+++ b/src/kiwano/2d/action/ActionWalk.h
@@ -32,8 +32,8 @@ namespace kiwano
ActionWalk(
Duration duration, /* 持续时长 */
bool rotating = false, /* 沿路线切线方向旋转 */
- float start = 0.f, /* 起点 */
- float end = 1.f, /* 终点 */
+ Float32 start = 0.f, /* 起点 */
+ Float32 end = 1.f, /* 终点 */
EaseFunc func = nullptr /* 速度变化 */
);
@@ -41,8 +41,8 @@ namespace kiwano
Duration duration, /* 持续时长 */
Geometry const& path, /* 路线 */
bool rotating = false, /* 沿路线切线方向旋转 */
- float start = 0.f, /* 起点 */
- float end = 1.f, /* 终点 */
+ Float32 start = 0.f, /* 起点 */
+ Float32 end = 1.f, /* 终点 */
EaseFunc func = nullptr /* 速度变化 */
);
@@ -81,7 +81,7 @@ namespace kiwano
void AddArc(
Point const& point, /* 终点 */
Size const& radius, /* 椭圆半径 */
- float rotation, /* 椭圆旋转角度 */
+ Float32 rotation, /* 椭圆旋转角度 */
bool clockwise = true, /* 顺时针 or 逆时针 */
bool is_small = true /* 是否取小于 180° 的弧 */
);
@@ -98,13 +98,13 @@ namespace kiwano
protected:
void Init(ActorPtr target) override;
- void UpdateTween(ActorPtr target, float percent) override;
+ void UpdateTween(ActorPtr target, Float32 percent) override;
protected:
bool rotating_;
- float start_;
- float end_;
- float length_;
+ Float32 start_;
+ Float32 end_;
+ Float32 length_;
Point start_pos_;
Geometry path_;
GeometrySink sink_;
diff --git a/src/kiwano/2d/action/Animation.cpp b/src/kiwano/2d/action/Animation.cpp
index 60c68f50..12869a4b 100644
--- a/src/kiwano/2d/action/Animation.cpp
+++ b/src/kiwano/2d/action/Animation.cpp
@@ -65,7 +65,7 @@ namespace kiwano
}
}
- void Animation::UpdateTween(ActorPtr target, float percent)
+ void Animation::UpdateTween(ActorPtr target, Float32 percent)
{
auto sprite_target = dynamic_cast(target.get());
@@ -73,7 +73,7 @@ namespace kiwano
const auto& frames = frame_seq_->GetFrames();
auto size = frames.size();
- auto index = std::min(static_cast(math::Floor(size * percent)), size - 1);
+ auto index = std::min(static_cast(math::Floor(size * percent)), size - 1);
sprite_target->SetFrame(frames[index]);
}
diff --git a/src/kiwano/2d/action/Animation.h b/src/kiwano/2d/action/Animation.h
index 09bab568..6b3f2048 100644
--- a/src/kiwano/2d/action/Animation.h
+++ b/src/kiwano/2d/action/Animation.h
@@ -55,7 +55,7 @@ namespace kiwano
protected:
void Init(ActorPtr target) override;
- void UpdateTween(ActorPtr target, float percent) override;
+ void UpdateTween(ActorPtr target, Float32 percent) override;
protected:
FrameSequencePtr frame_seq_;
diff --git a/src/kiwano/base/AsyncTask.cpp b/src/kiwano/base/AsyncTask.cpp
index 66d94f6e..9235235c 100644
--- a/src/kiwano/base/AsyncTask.cpp
+++ b/src/kiwano/base/AsyncTask.cpp
@@ -24,7 +24,7 @@
namespace kiwano
{
AsyncTask::AsyncTask()
- : thread_(bind_func(this, &AsyncTask::TaskThread))
+ : thread_(Closure(this, &AsyncTask::TaskThread))
{
}
@@ -74,7 +74,7 @@ namespace kiwano
func_mutex_.unlock();
}
- Application::PreformInMainThread(bind_func(this, &AsyncTask::Complete));
+ Application::PreformInMainThread(Closure(this, &AsyncTask::Complete));
}
void AsyncTask::Complete()
diff --git a/src/kiwano/base/Component.h b/src/kiwano/base/Component.h
index 0628e93e..f68116a2 100644
--- a/src/kiwano/base/Component.h
+++ b/src/kiwano/base/Component.h
@@ -42,6 +42,6 @@ namespace kiwano
virtual void AfterRender() {}
virtual void HandleEvent(Event&) {}
- virtual void HandleMessage(HWND, UINT, WPARAM, LPARAM) {}
+ virtual void HandleMessage(HWND, UInt32, WPARAM, LPARAM) {}
};
}
diff --git a/src/kiwano/base/Event.hpp b/src/kiwano/base/Event.hpp
index 36dc8b9f..88eb4d4b 100644
--- a/src/kiwano/base/Event.hpp
+++ b/src/kiwano/base/Event.hpp
@@ -27,8 +27,8 @@ namespace kiwano
// 鼠标事件
struct MouseEvent
{
- float x;
- float y;
+ Float32 x;
+ Float32 y;
bool left_btn_down; // 左键是否按下
bool right_btn_down; // 右键是否按下
@@ -36,27 +36,27 @@ namespace kiwano
{
struct // Events::MouseDown | Events::MouseUp | Events::MouseClick
{
- int button;
+ Int32 button;
};
struct // Events::MouseWheel
{
- float wheel;
+ Float32 wheel;
};
};
- static bool Check(UINT type);
+ static bool Check(UInt32 type);
};
// 键盘事件
struct KeyboardEvent
{
- int count;
+ Int32 count;
union
{
struct // Events::KeyDown | Events::KeyUp
{
- int code; // enum KeyCode
+ Int32 code; // enum KeyCode
};
struct // Events::Char
@@ -65,7 +65,7 @@ namespace kiwano
};
};
- static bool Check(UINT type);
+ static bool Check(UInt32 type);
};
// 窗口事件
@@ -75,14 +75,14 @@ namespace kiwano
{
struct // Events::WindowMoved
{
- int x;
- int y;
+ Int32 x;
+ Int32 y;
};
struct // Events::WindowResized
{
- int width;
- int height;
+ Int32 width;
+ Int32 height;
};
struct // Events::WindowFocusChanged
@@ -92,11 +92,11 @@ namespace kiwano
struct // Events::WindowTitleChanged
{
- const wchar_t* title;
+ const WChar* title;
};
};
- static bool Check(UINT type);
+ static bool Check(UInt32 type);
};
// 自定义事件
@@ -110,7 +110,7 @@ namespace kiwano
// 事件
struct KGE_API Event
{
- enum Type : UINT
+ enum Type : UInt32
{
First,
@@ -144,7 +144,7 @@ namespace kiwano
Last
};
- UINT type;
+ UInt32 type;
Actor* target;
union
@@ -155,23 +155,23 @@ namespace kiwano
CustomEvent custom;
};
- Event(UINT type = Type::First) : type(type), target(nullptr) {}
+ Event(UInt32 type = Type::First) : type(type), target(nullptr) {}
};
// Check-functions
- inline bool MouseEvent::Check(UINT type)
+ inline bool MouseEvent::Check(UInt32 type)
{
return type > Event::MouseFirst && type < Event::MouseLast;
}
- inline bool KeyboardEvent::Check(UINT type)
+ inline bool KeyboardEvent::Check(UInt32 type)
{
return type > Event::KeyFirst && type < Event::KeyLast;
}
- inline bool WindowEvent::Check(UINT type)
+ inline bool WindowEvent::Check(UInt32 type)
{
return type > Event::WindowFirst && type < Event::WindowLast;
}
diff --git a/src/kiwano/base/EventDispatcher.cpp b/src/kiwano/base/EventDispatcher.cpp
index d46fbb3b..4626598c 100644
--- a/src/kiwano/base/EventDispatcher.cpp
+++ b/src/kiwano/base/EventDispatcher.cpp
@@ -51,7 +51,7 @@ namespace kiwano
return listener;
}
- void EventDispatcher::AddListener(UINT type, EventCallback callback, String const& name)
+ void EventDispatcher::AddListener(UInt32 type, EventCallback callback, String const& name)
{
EventListenerPtr listener = new EventListener(type, callback, name);
if (listener)
@@ -96,7 +96,7 @@ namespace kiwano
}
}
- void EventDispatcher::StartListeners(UINT type)
+ void EventDispatcher::StartListeners(UInt32 type)
{
for (auto listener = listeners_.first_item(); listener; listener = listener->next_item())
{
@@ -107,7 +107,7 @@ namespace kiwano
}
}
- void EventDispatcher::StopListeners(UINT type)
+ void EventDispatcher::StopListeners(UInt32 type)
{
for (auto listener = listeners_.first_item(); listener; listener = listener->next_item())
{
@@ -118,7 +118,7 @@ namespace kiwano
}
}
- void EventDispatcher::RemoveListeners(UINT type)
+ void EventDispatcher::RemoveListeners(UInt32 type)
{
EventListenerPtr next;
for (auto listener = listeners_.first_item(); listener; listener = next)
diff --git a/src/kiwano/base/EventDispatcher.h b/src/kiwano/base/EventDispatcher.h
index a742421f..02581f8c 100644
--- a/src/kiwano/base/EventDispatcher.h
+++ b/src/kiwano/base/EventDispatcher.h
@@ -35,7 +35,7 @@ namespace kiwano
// 添加监听器
void AddListener(
- UINT type,
+ UInt32 type,
EventCallback callback,
String const& name = L""
);
@@ -57,17 +57,17 @@ namespace kiwano
// 启动监听器
void StartListeners(
- UINT type
+ UInt32 type
);
// 停止监听器
void StopListeners(
- UINT type
+ UInt32 type
);
// 移除监听器
void RemoveListeners(
- UINT type
+ UInt32 type
);
virtual void Dispatch(Event& evt);
diff --git a/src/kiwano/base/EventListener.cpp b/src/kiwano/base/EventListener.cpp
index 1b5c1f81..336be7a5 100644
--- a/src/kiwano/base/EventListener.cpp
+++ b/src/kiwano/base/EventListener.cpp
@@ -23,7 +23,7 @@
namespace kiwano
{
- EventListener::EventListener(UINT type, EventCallback const & callback, String const & name)
+ EventListener::EventListener(UInt32 type, EventCallback const & callback, String const & name)
: type_(type)
, callback_(callback)
, running_(true)
diff --git a/src/kiwano/base/EventListener.h b/src/kiwano/base/EventListener.h
index f07e83f3..8764eec3 100644
--- a/src/kiwano/base/EventListener.h
+++ b/src/kiwano/base/EventListener.h
@@ -42,7 +42,7 @@ namespace kiwano
public:
EventListener(
- UINT type,
+ UInt32 type,
EventCallback const& callback,
String const& name = L""
);
@@ -57,7 +57,7 @@ namespace kiwano
protected:
bool running_;
- UINT type_;
+ UInt32 type_;
EventCallback callback_;
};
}
diff --git a/src/kiwano/base/Input.cpp b/src/kiwano/base/Input.cpp
index 6d4f86af..e38dde26 100644
--- a/src/kiwano/base/Input.cpp
+++ b/src/kiwano/base/Input.cpp
@@ -38,7 +38,7 @@ namespace kiwano
{
}
- void Input::UpdateKey(int key, bool down)
+ void Input::UpdateKey(Int32 key, bool down)
{
if (down && !keys_[key])
keys_pressed_[key] = true;
@@ -50,7 +50,7 @@ namespace kiwano
want_update_ = true;
}
- void Input::UpdateMousePos(float x, float y)
+ void Input::UpdateMousePos(Float32 x, Float32 y)
{
mouse_pos_x_ = x;
mouse_pos_y_ = y;
@@ -67,7 +67,7 @@ namespace kiwano
}
}
- void Input::HandleMessage(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
+ void Input::HandleMessage(HWND hwnd, UInt32 msg, WPARAM wparam, LPARAM lparam)
{
switch (msg)
{
@@ -86,7 +86,7 @@ namespace kiwano
if (msg == WM_LBUTTONDOWN || msg == WM_LBUTTONUP) { UpdateKey(VK_LBUTTON, (msg == WM_LBUTTONDOWN) ? true : false); }
else if (msg == WM_RBUTTONDOWN || msg == WM_RBUTTONUP) { UpdateKey(VK_RBUTTON, (msg == WM_RBUTTONDOWN) ? true : false); }
else if (msg == WM_MBUTTONDOWN || msg == WM_MBUTTONUP) { UpdateKey(VK_MBUTTON, (msg == WM_MBUTTONDOWN) ? true : false); }
- else if (msg == WM_MOUSEMOVE) { UpdateMousePos(static_cast(GET_X_LPARAM(lparam)), static_cast(GET_Y_LPARAM(lparam))); }
+ else if (msg == WM_MOUSEMOVE) { UpdateMousePos(static_cast(GET_X_LPARAM(lparam)), static_cast(GET_Y_LPARAM(lparam))); }
break;
}
@@ -97,35 +97,41 @@ namespace kiwano
case WM_SYSKEYUP:
{
bool down = msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN;
- UpdateKey((int)wparam, down);
+ UpdateKey((Int32)wparam, down);
}
}
}
- bool Input::IsDown(int key_or_btn)
+ bool Input::IsDown(Int32 key_or_btn)
{
KGE_ASSERT(key_or_btn >= 0 && key_or_btn < KEY_NUM);
- return keys_[key_or_btn];
+ if (key_or_btn >= 0 && key_or_btn < KEY_NUM)
+ return keys_[key_or_btn];
+ return false;
}
- bool Input::WasPressed(int key_or_btn)
+ bool Input::WasPressed(Int32 key_or_btn)
{
KGE_ASSERT(key_or_btn >= 0 && key_or_btn < KEY_NUM);
- return keys_pressed_[key_or_btn];
+ if (key_or_btn >= 0 && key_or_btn < KEY_NUM)
+ return keys_pressed_[key_or_btn];
+ return false;
}
- bool Input::WasReleased(int key_or_btn)
+ bool Input::WasReleased(Int32 key_or_btn)
{
KGE_ASSERT(key_or_btn >= 0 && key_or_btn < KEY_NUM);
- return keys_released_[key_or_btn];
+ if (key_or_btn >= 0 && key_or_btn < KEY_NUM)
+ return keys_released_[key_or_btn];
+ return false;
}
- float Input::GetMouseX()
+ Float32 Input::GetMouseX()
{
return mouse_pos_x_;
}
- float Input::GetMouseY()
+ Float32 Input::GetMouseY()
{
return mouse_pos_y_;
}
@@ -134,4 +140,4 @@ namespace kiwano
{
return Point{ mouse_pos_x_, mouse_pos_y_ };
}
-}
\ No newline at end of file
+}
diff --git a/src/kiwano/base/Input.h b/src/kiwano/base/Input.h
index 2cbc24bc..3ae61dbf 100644
--- a/src/kiwano/base/Input.h
+++ b/src/kiwano/base/Input.h
@@ -36,24 +36,24 @@ namespace kiwano
public:
// 检测键盘或鼠标按键是否正被按下
bool IsDown(
- int key_or_btn
+ Int32 key_or_btn
);
// 检测键盘或鼠标按键是否刚被点击
bool WasPressed(
- int key_or_btn
+ Int32 key_or_btn
);
// 检测键盘或鼠标按键是否刚抬起
bool WasReleased(
- int key_or_btn
+ Int32 key_or_btn
);
// 获得鼠标 x 坐标
- float GetMouseX();
+ Float32 GetMouseX();
// 获得鼠标 y 坐标
- float GetMouseY();
+ Float32 GetMouseY();
// 获得鼠标坐标
Point GetMousePos();
@@ -65,11 +65,11 @@ namespace kiwano
void AfterUpdate() override;
- void HandleMessage(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) override;
+ void HandleMessage(HWND hwnd, UInt32 msg, WPARAM wparam, LPARAM lparam) override;
- void UpdateKey(int, bool);
+ void UpdateKey(Int32, bool);
- void UpdateMousePos(float, float);
+ void UpdateMousePos(Float32, Float32);
protected:
Input();
@@ -77,13 +77,13 @@ namespace kiwano
~Input();
protected:
- static const int KEY_NUM = 256;
+ static const Int32 KEY_NUM = 256;
bool want_update_;
bool keys_[KEY_NUM];
bool keys_pressed_[KEY_NUM];
bool keys_released_[KEY_NUM];
- float mouse_pos_x_;
- float mouse_pos_y_;
+ Float32 mouse_pos_x_;
+ Float32 mouse_pos_y_;
};
}
diff --git a/src/kiwano/base/Logger.cpp b/src/kiwano/base/Logger.cpp
index 7f72fc9e..02cb9fed 100644
--- a/src/kiwano/base/Logger.cpp
+++ b/src/kiwano/base/Logger.cpp
@@ -216,7 +216,7 @@ namespace kiwano
return error_stream_.rdbuf(buf);
}
- void Logger::Printf(const wchar_t* format, ...)
+ void Logger::Printf(const WChar* format, ...)
{
va_list args = nullptr;
va_start(args, format);
@@ -226,7 +226,7 @@ namespace kiwano
va_end(args);
}
- void Logger::Messagef(const wchar_t* format, ...)
+ void Logger::Messagef(const WChar* format, ...)
{
using namespace __console_colors;
@@ -238,7 +238,7 @@ namespace kiwano
va_end(args);
}
- void Logger::Warningf(const wchar_t* format, ...)
+ void Logger::Warningf(const WChar* format, ...)
{
using namespace __console_colors;
@@ -250,7 +250,7 @@ namespace kiwano
va_end(args);
}
- void Logger::Errorf(const wchar_t* format, ...)
+ void Logger::Errorf(const WChar* format, ...)
{
using namespace __console_colors;
@@ -262,7 +262,7 @@ namespace kiwano
va_end(args);
}
- void Logger::Outputf(std::wostream& os, std::wostream& (*color)(std::wostream&), const wchar_t* prompt, const wchar_t* format, va_list args) const
+ void Logger::Outputf(std::wostream& os, std::wostream& (*color)(std::wostream&), const WChar* prompt, const WChar* format, va_list args) const
{
if (enabled_)
{
@@ -275,9 +275,9 @@ namespace kiwano
}
}
- std::wstring Logger::MakeOutputStringf(const wchar_t* prompt, const wchar_t* format, va_list args) const
+ std::wstring Logger::MakeOutputStringf(const WChar* prompt, const WChar* format, va_list args) const
{
- static wchar_t temp_buffer[1024 * 3 + 1];
+ static WChar temp_buffer[1024 * 3 + 1];
std::wstringstream ss;
ss << Logger::OutPrefix;
diff --git a/src/kiwano/base/Logger.h b/src/kiwano/base/Logger.h
index af05f629..b4934b97 100644
--- a/src/kiwano/base/Logger.h
+++ b/src/kiwano/base/Logger.h
@@ -66,13 +66,13 @@ namespace kiwano
// 禁用 Logger
void Disable();
- void Printf(const wchar_t* format, ...);
+ void Printf(const WChar* format, ...);
- void Messagef(const wchar_t * format, ...);
+ void Messagef(const WChar * format, ...);
- void Warningf(const wchar_t* format, ...);
+ void Warningf(const WChar* format, ...);
- void Errorf(const wchar_t* format, ...);
+ void Errorf(const WChar* format, ...);
template
void Print(_Args&& ... args);
@@ -109,18 +109,18 @@ namespace kiwano
~Logger();
- void Outputf(std::wostream& os, std::wostream&(*color)(std::wostream&), const wchar_t* prompt, const wchar_t* format, va_list args) const;
+ void Outputf(std::wostream& os, std::wostream&(*color)(std::wostream&), const WChar* prompt, const WChar* format, va_list args) const;
- std::wstring MakeOutputStringf(const wchar_t* prompt, const wchar_t* format, va_list args) const;
+ std::wstring MakeOutputStringf(const WChar* prompt, const WChar* format, va_list args) const;
template
- void OutputLine(std::wostream& os, std::wostream& (*color)(std::wostream&), const wchar_t* prompt, _Args&& ... args) const;
+ void OutputLine(std::wostream& os, std::wostream& (*color)(std::wostream&), const WChar* prompt, _Args&& ... args) const;
template
- void Output(std::wostream& os, std::wostream& (*color)(std::wostream&), const wchar_t* prompt, _Args&& ... args) const;
+ void Output(std::wostream& os, std::wostream& (*color)(std::wostream&), const WChar* prompt, _Args&& ... args) const;
template
- std::wstring MakeOutputString(const wchar_t* prompt, _Args&& ... args) const;
+ std::wstring MakeOutputString(const WChar* prompt, _Args&& ... args) const;
void ResetConsoleColor() const;
@@ -235,7 +235,7 @@ namespace kiwano
}
template
- void Logger::OutputLine(std::wostream& os, std::wostream& (*color)(std::wostream&), const wchar_t* prompt, _Args&& ... args) const
+ void Logger::OutputLine(std::wostream& os, std::wostream& (*color)(std::wostream&), const WChar* prompt, _Args&& ... args) const
{
if (enabled_)
{
@@ -247,7 +247,7 @@ namespace kiwano
}
template
- void Logger::Output(std::wostream& os, std::wostream& (*color)(std::wostream&), const wchar_t* prompt, _Args&& ... args) const
+ void Logger::Output(std::wostream& os, std::wostream& (*color)(std::wostream&), const WChar* prompt, _Args&& ... args) const
{
if (enabled_)
{
@@ -261,7 +261,7 @@ namespace kiwano
}
template
- std::wstring Logger::MakeOutputString(const wchar_t* prompt, _Args&& ... args) const
+ std::wstring Logger::MakeOutputString(const WChar* prompt, _Args&& ... args) const
{
std::wstringstream ss;
ss << Logger::OutPrefix;
@@ -269,7 +269,7 @@ namespace kiwano
if (prompt)
ss << prompt;
- (void)std::initializer_list{((ss << ' ' << args), 0)...};
+ (void)std::initializer_list{((ss << ' ' << args), 0)...};
return ss.str();
}
diff --git a/src/kiwano/base/ObjectBase.cpp b/src/kiwano/base/ObjectBase.cpp
index b3020125..28e1bb61 100644
--- a/src/kiwano/base/ObjectBase.cpp
+++ b/src/kiwano/base/ObjectBase.cpp
@@ -30,7 +30,7 @@ namespace kiwano
Vector tracing_objects;
}
- unsigned int ObjectBase::last_object_id = 0;
+ UInt32 ObjectBase::last_object_id = 0;
ObjectBase::ObjectBase()
: tracing_leak_(false)
diff --git a/src/kiwano/base/ObjectBase.h b/src/kiwano/base/ObjectBase.h
index e527fbf3..3737d9d5 100644
--- a/src/kiwano/base/ObjectBase.h
+++ b/src/kiwano/base/ObjectBase.h
@@ -46,7 +46,7 @@ namespace kiwano
inline bool IsName(String const& name) const { return name_ ? (*name_ == name) : name.empty(); }
- inline unsigned int GetObjectID() const { return id_; }
+ inline UInt32 GetObjectID() const { return id_; }
String DumpObject();
@@ -71,7 +71,7 @@ namespace kiwano
void* user_data_;
String* name_;
- const unsigned int id_;
- static unsigned int last_object_id;
+ const UInt32 id_;
+ static UInt32 last_object_id;
};
}
diff --git a/src/kiwano/base/Resource.cpp b/src/kiwano/base/Resource.cpp
index 1ea7ee67..a6b2e336 100644
--- a/src/kiwano/base/Resource.cpp
+++ b/src/kiwano/base/Resource.cpp
@@ -31,7 +31,7 @@ namespace kiwano
}
- Resource::Resource(UINT id, LPCWSTR type)
+ Resource::Resource(UInt32 id, LPCWSTR type)
: id_(id)
, type_(type)
{
@@ -75,7 +75,7 @@ namespace kiwano
}
data_.buffer = static_cast(buffer);
- data_.size = static_cast(size);
+ data_.size = static_cast(size);
} while (0);
return data_;
diff --git a/src/kiwano/base/Resource.h b/src/kiwano/base/Resource.h
index 32f990d3..0b5acb61 100644
--- a/src/kiwano/base/Resource.h
+++ b/src/kiwano/base/Resource.h
@@ -39,7 +39,7 @@ namespace kiwano
struct Data
{
void* buffer;
- UINT32 size;
+ UInt32 size;
inline Data() : buffer(nullptr), size(0) {}
@@ -49,19 +49,19 @@ namespace kiwano
Resource();
Resource(
- UINT id, /* 资源名称 */
+ UInt32 id, /* 资源名称 */
LPCWSTR type /* 资源类型 */
);
// 获取二进制数据
Resource::Data GetData() const;
- inline UINT GetId() const { return id_; }
+ inline UInt32 GetId() const { return id_; }
inline LPCWSTR GetType() const { return type_; }
private:
- UINT id_;
+ UInt32 id_;
LPCWSTR type_;
mutable Resource::Data data_;
};
diff --git a/src/kiwano/base/Timer.cpp b/src/kiwano/base/Timer.cpp
index 1da92c81..cc34b2a9 100644
--- a/src/kiwano/base/Timer.cpp
+++ b/src/kiwano/base/Timer.cpp
@@ -27,7 +27,7 @@ namespace kiwano
{
}
- Timer::Timer(Callback const& func, Duration delay, int times, String const& name)
+ Timer::Timer(Callback const& func, Duration delay, Int32 times, String const& name)
: running_(true)
, run_times_(0)
, total_times_(times)
diff --git a/src/kiwano/base/Timer.h b/src/kiwano/base/Timer.h
index e82211dd..20d066af 100644
--- a/src/kiwano/base/Timer.h
+++ b/src/kiwano/base/Timer.h
@@ -48,7 +48,7 @@ namespace kiwano
explicit Timer(
Callback const& func, /* 执行函数 */
Duration delay, /* 时间间隔(秒) */
- int times = -1, /* 执行次数(设 -1 为永久执行) */
+ Int32 times = -1, /* 执行次数(设 -1 为永久执行) */
String const& name = L"" /* 任务名称 */
);
@@ -68,8 +68,8 @@ namespace kiwano
protected:
bool running_;
- int run_times_;
- int total_times_;
+ Int32 run_times_;
+ Int32 total_times_;
Duration delay_;
Duration delta_;
Callback callback_;
diff --git a/src/kiwano/base/Window.cpp b/src/kiwano/base/Window.cpp
index 00afa86c..c2027c29 100644
--- a/src/kiwano/base/Window.cpp
+++ b/src/kiwano/base/Window.cpp
@@ -31,9 +31,9 @@ namespace kiwano
{
MONITORINFOEX GetMoniterInfoEx(HWND hwnd);
- void AdjustWindow(UINT width, UINT height, DWORD style, UINT* win_width, UINT* win_height);
+ void AdjustWindow(UInt32 width, UInt32 height, DWORD style, UInt32* win_width, UInt32* win_height);
- void ChangeFullScreenResolution(int width, int height, WCHAR* device_name);
+ void ChangeFullScreenResolution(Int32 width, Int32 height, WCHAR* device_name);
void RestoreResolution(WCHAR* device_name);
}
@@ -66,7 +66,7 @@ namespace kiwano
}
}
- void Window::Init(String const& title, int width, int height, LPCWSTR icon, bool fullscreen, WNDPROC proc)
+ void Window::Init(String const& title, Int32 width, Int32 height, LPCWSTR icon, bool fullscreen, WNDPROC proc)
{
HINSTANCE hinst = GetModuleHandleW(nullptr);
WNDCLASSEX wcex = { 0 };
@@ -99,12 +99,12 @@ namespace kiwano
::GetMonitorInfoW(monitor, &monitor_info_ex);
// Save the device name
- int len = lstrlenW(monitor_info_ex.szDevice);
+ Int32 len = lstrlenW(monitor_info_ex.szDevice);
device_name_ = new WCHAR[len + 1];
lstrcpyW(device_name_, monitor_info_ex.szDevice);
- int left = -1;
- int top = -1;
+ Int32 left = -1;
+ Int32 top = -1;
is_fullscreen_ = fullscreen;
@@ -121,10 +121,10 @@ namespace kiwano
}
else
{
- UINT screenw = monitor_info_ex.rcWork.right - monitor_info_ex.rcWork.left;
- UINT screenh = monitor_info_ex.rcWork.bottom - monitor_info_ex.rcWork.top;
+ UInt32 screenw = monitor_info_ex.rcWork.right - monitor_info_ex.rcWork.left;
+ UInt32 screenh = monitor_info_ex.rcWork.bottom - monitor_info_ex.rcWork.top;
- UINT win_width, win_height;
+ UInt32 win_width, win_height;
AdjustWindow(
width,
height,
@@ -185,7 +185,7 @@ namespace kiwano
{
if (handle_)
{
- wchar_t title[256];
+ WChar title[256];
::GetWindowTextW(handle_, title, 256);
return title;
}
@@ -201,19 +201,19 @@ namespace kiwano
Size Window::GetSize() const
{
return Size{
- static_cast(width_),
- static_cast(height_)
+ static_cast(width_),
+ static_cast(height_)
};
}
- float Window::GetWidth() const
+ Float32 Window::GetWidth() const
{
- return static_cast(width_);
+ return static_cast(width_);
}
- float Window::GetHeight() const
+ Float32 Window::GetHeight() const
{
- return static_cast(height_);
+ return static_cast(height_);
}
void Window::SetIcon(LPCWSTR icon_resource)
@@ -235,11 +235,11 @@ namespace kiwano
}
}
- void Window::Resize(int width, int height)
+ void Window::Resize(Int32 width, Int32 height)
{
if (handle_ && !is_fullscreen_)
{
- RECT rc = { 0, 0, int(width), int(height) };
+ RECT rc = { 0, 0, Int32(width), Int32(height) };
::AdjustWindowRect(&rc, GetWindowStyle(), false);
width = rc.right - rc.left;
@@ -248,7 +248,7 @@ namespace kiwano
}
}
- void Window::SetFullscreen(bool fullscreen, int width, int height)
+ void Window::SetFullscreen(bool fullscreen, Int32 width, Int32 height)
{
if (is_fullscreen_ != fullscreen || width != width_ || height != height_)
{
@@ -275,14 +275,14 @@ namespace kiwano
MONITORINFOEX info = GetMoniterInfoEx(handle_);
- UINT screenw = info.rcWork.right - info.rcWork.left;
- UINT screenh = info.rcWork.bottom - info.rcWork.top;
+ UInt32 screenw = info.rcWork.right - info.rcWork.left;
+ UInt32 screenh = info.rcWork.bottom - info.rcWork.top;
- UINT win_width, win_height;
+ UInt32 win_width, win_height;
AdjustWindow(width, height, GetWindowStyle(), &win_width, &win_height);
- int left = screenw > win_width ? ((screenw - win_width) / 2) : 0;
- int top = screenh > win_height ? ((screenh - win_height) / 2) : 0;
+ Int32 left = screenw > win_width ? ((screenw - win_width) / 2) : 0;
+ Int32 top = screenh > win_height ? ((screenh - win_height) / 2) : 0;
::SetWindowLongPtr(handle_, GWL_STYLE, GetWindowStyle());
::SetWindowPos(handle_, HWND_NOTOPMOST, left, top, win_width, win_height, SWP_DRAWFRAME | SWP_FRAMECHANGED);
@@ -376,10 +376,10 @@ namespace kiwano
return monitor_info;
}
- void AdjustWindow(UINT width, UINT height, DWORD style, UINT* win_width, UINT* win_height)
+ void AdjustWindow(UInt32 width, UInt32 height, DWORD style, UInt32* win_width, UInt32* win_height)
{
RECT rc;
- ::SetRect(&rc, 0, 0, (int)width, (int)height);
+ ::SetRect(&rc, 0, 0, (Int32)width, (Int32)height);
::AdjustWindowRect(&rc, style, false);
*win_width = rc.right - rc.left;
@@ -387,8 +387,8 @@ namespace kiwano
MONITORINFOEX info = GetMoniterInfoEx(NULL);
- UINT screenw = info.rcWork.right - info.rcWork.left;
- UINT screenh = info.rcWork.bottom - info.rcWork.top;
+ UInt32 screenw = info.rcWork.right - info.rcWork.left;
+ UInt32 screenh = info.rcWork.bottom - info.rcWork.top;
if (*win_width > screenw)
*win_width = screenw;
@@ -396,7 +396,7 @@ namespace kiwano
*win_height = screenh;
}
- void ChangeFullScreenResolution(int width, int height, WCHAR* device_name)
+ void ChangeFullScreenResolution(Int32 width, Int32 height, WCHAR* device_name)
{
DEVMODE mode;
diff --git a/src/kiwano/base/Window.h b/src/kiwano/base/Window.h
index 19cf280a..8c649f74 100644
--- a/src/kiwano/base/Window.h
+++ b/src/kiwano/base/Window.h
@@ -39,10 +39,10 @@ namespace kiwano
Size GetSize() const;
// 获取窗口宽度
- float GetWidth() const;
+ Float32 GetWidth() const;
// 获取窗口高度
- float GetHeight() const;
+ Float32 GetHeight() const;
// 设置标题
void SetTitle(String const& title);
@@ -51,10 +51,10 @@ namespace kiwano
void SetIcon(LPCWSTR icon_resource);
// 重设窗口大小
- void Resize(int width, int height);
+ void Resize(Int32 width, Int32 height);
// 设置全屏模式
- void SetFullscreen(bool fullscreen, int width, int height);
+ void SetFullscreen(bool fullscreen, Int32 width, Int32 height);
// 设置鼠标指针
void SetMouseCursor(MouseCursor cursor);
@@ -62,8 +62,8 @@ namespace kiwano
public:
void Init(
String const& title,
- int width,
- int height,
+ Int32 width,
+ Int32 height,
LPCWSTR icon,
bool fullscreen,
WNDPROC proc
@@ -87,8 +87,8 @@ namespace kiwano
private:
HWND handle_;
bool is_fullscreen_;
- int width_;
- int height_;
+ Int32 width_;
+ Int32 height_;
WCHAR* device_name_;
MouseCursor mouse_cursor_;
};
diff --git a/src/kiwano/base/keys.hpp b/src/kiwano/base/keys.hpp
index 6d668554..e37dadbd 100644
--- a/src/kiwano/base/keys.hpp
+++ b/src/kiwano/base/keys.hpp
@@ -26,7 +26,7 @@ namespace kiwano
// 鼠标按键
struct MouseButton
{
- typedef int Value;
+ typedef Int32 Value;
enum : Value
{
@@ -40,7 +40,7 @@ namespace kiwano
// 按键键值
struct KeyCode
{
- typedef int Value;
+ typedef Int32 Value;
enum : Value
{
diff --git a/src/kiwano/base/time.cpp b/src/kiwano/base/time.cpp
index eba6b604..bf97e79e 100644
--- a/src/kiwano/base/time.cpp
+++ b/src/kiwano/base/time.cpp
@@ -119,25 +119,25 @@ namespace kiwano
{
}
- float Duration::Seconds() const
+ Float32 Duration::Seconds() const
{
long sec = milliseconds_ / Sec.milliseconds_;
long ms = milliseconds_ % Sec.milliseconds_;
- return static_cast(sec) + static_cast(ms) / 1000.f;
+ return static_cast(sec) + static_cast(ms) / 1000.f;
}
- float Duration::Minutes() const
+ Float32 Duration::Minutes() const
{
long min = milliseconds_ / Min.milliseconds_;
long ms = milliseconds_ % Min.milliseconds_;
- return static_cast(min) + static_cast(ms) / (60 * 1000.f);
+ return static_cast(min) + static_cast(ms) / (60 * 1000.f);
}
- float Duration::Hours() const
+ Float32 Duration::Hours() const
{
long hour = milliseconds_ / Hour.milliseconds_;
long ms = milliseconds_ % Hour.milliseconds_;
- return static_cast(hour) + static_cast(ms) / (60 * 60 * 1000.f);
+ return static_cast(hour) + static_cast(ms) / (60 * 60 * 1000.f);
}
String kiwano::time::Duration::ToString() const
@@ -172,14 +172,14 @@ namespace kiwano
if (ms != 0)
{
- auto float_to_str = [](float val) -> String
+ auto float_to_str = [](Float32 val) -> String
{
- wchar_t buf[10] = {};
+ WChar buf[10] = {};
::swprintf_s(buf, L"%g", val);
return String(buf);
};
- result.append(float_to_str(static_cast(sec) + static_cast(ms) / 1000.f))
+ result.append(float_to_str(static_cast(sec) + static_cast(ms) / 1000.f))
.append(L"s");
}
else if (sec != 0)
@@ -219,9 +219,9 @@ namespace kiwano
return milliseconds_ <= other.milliseconds_;
}
- float kiwano::time::Duration::operator/(const Duration & other) const
+ Float32 kiwano::time::Duration::operator/(const Duration & other) const
{
- return static_cast(milliseconds_) / other.milliseconds_;
+ return static_cast(milliseconds_) / other.milliseconds_;
}
const Duration Duration::operator+(const Duration & other) const
@@ -239,7 +239,7 @@ namespace kiwano
return Duration(-milliseconds_);
}
- const Duration Duration::operator*(int val) const
+ const Duration Duration::operator*(Int32 val) const
{
return Duration(milliseconds_ * val);
}
@@ -249,12 +249,12 @@ namespace kiwano
return Duration(static_cast(milliseconds_ * val));
}
- const Duration Duration::operator*(float val) const
+ const Duration Duration::operator*(Float32 val) const
{
return Duration(static_cast(milliseconds_ * val));
}
- const Duration Duration::operator*(double val) const
+ const Duration Duration::operator*(Float64 val) const
{
return Duration(static_cast(milliseconds_ * val));
}
@@ -264,17 +264,17 @@ namespace kiwano
return Duration(static_cast(milliseconds_ * val));
}
- const Duration Duration::operator/(int val) const
+ const Duration Duration::operator/(Int32 val) const
{
return Duration(milliseconds_ / val);
}
- const Duration Duration::operator/(float val) const
+ const Duration Duration::operator/(Float32 val) const
{
return Duration(static_cast(milliseconds_ / val));
}
- const Duration Duration::operator/(double val) const
+ const Duration Duration::operator/(Float64 val) const
{
return Duration(static_cast(milliseconds_ / val));
}
@@ -291,68 +291,68 @@ namespace kiwano
return (*this);
}
- Duration & Duration::operator*=(int val)
+ Duration & Duration::operator*=(Int32 val)
{
milliseconds_ *= val;
return (*this);
}
- Duration & Duration::operator/=(int val)
+ Duration & Duration::operator/=(Int32 val)
{
milliseconds_ = static_cast(milliseconds_ / val);
return (*this);
}
- Duration & Duration::operator*=(float val)
+ Duration & Duration::operator*=(Float32 val)
{
milliseconds_ = static_cast(milliseconds_ * val);
return (*this);
}
- Duration & Duration::operator/=(float val)
+ Duration & Duration::operator/=(Float32 val)
{
milliseconds_ = static_cast(milliseconds_ / val);
return (*this);
}
- Duration & Duration::operator*=(double val)
+ Duration & Duration::operator*=(Float64 val)
{
milliseconds_ = static_cast(milliseconds_ * val);
return (*this);
}
- Duration & Duration::operator/=(double val)
+ Duration & Duration::operator/=(Float64 val)
{
milliseconds_ = static_cast(milliseconds_ / val);
return (*this);
}
- const Duration kiwano::time::operator*(int val, const Duration & dur)
+ const Duration kiwano::time::operator*(Int32 val, const Duration & dur)
{
return dur * val;
}
- const Duration kiwano::time::operator/(int val, const Duration & dur)
+ const Duration kiwano::time::operator/(Int32 val, const Duration & dur)
{
return dur / val;
}
- const Duration kiwano::time::operator*(float val, const Duration & dur)
+ const Duration kiwano::time::operator*(Float32 val, const Duration & dur)
{
return dur * val;
}
- const Duration kiwano::time::operator/(float val, const Duration & dur)
+ const Duration kiwano::time::operator/(Float32 val, const Duration & dur)
{
return dur / val;
}
- const Duration kiwano::time::operator*(double val, const Duration & dur)
+ const Duration kiwano::time::operator*(Float64 val, const Duration & dur)
{
return dur * val;
}
- const Duration kiwano::time::operator/(double val, const Duration & dur)
+ const Duration kiwano::time::operator/(Float64 val, const Duration & dur)
{
return dur / val;
}
@@ -364,8 +364,8 @@ namespace kiwano
Duration Duration::Parse(const String& str)
{
- size_t len = str.length();
- size_t pos = 0;
+ UInt32 len = str.length();
+ UInt32 pos = 0;
bool negative = false;
Duration d;
@@ -387,10 +387,10 @@ namespace kiwano
while (pos < len)
{
// 数值
- size_t i = pos;
+ UInt32 i = pos;
for (; i < len; ++i)
{
- wchar_t ch = str[i];
+ WChar ch = str[i];
if (!(ch == L'.' || L'0' <= ch && ch <= L'9'))
{
break;
@@ -409,7 +409,7 @@ namespace kiwano
// 单位
for (; i < len; ++i)
{
- wchar_t ch = str[i];
+ WChar ch = str[i];
if (ch == L'.' || L'0' <= ch && ch <= L'9')
{
break;
@@ -425,7 +425,7 @@ namespace kiwano
return Duration();
}
- double num = std::wcstod(num_str.c_str(), nullptr);
+ Float64 num = std::wcstod(num_str.c_str(), nullptr);
Duration unit = unit_map.at(unit_str);
d += unit * num;
}
diff --git a/src/kiwano/base/time.h b/src/kiwano/base/time.h
index 877366e7..16c40b06 100644
--- a/src/kiwano/base/time.h
+++ b/src/kiwano/base/time.h
@@ -51,24 +51,24 @@ namespace kiwano
inline long Milliseconds() const { return milliseconds_; }
// 转化为秒
- float Seconds() const;
+ Float32 Seconds() const;
// 转化为分钟
- float Minutes() const;
+ Float32 Minutes() const;
// 转化为小时
- float Hours() const;
+ Float32 Hours() const;
// 时长是否是零
inline bool IsZero() const { return milliseconds_ == 0LL; }
inline void SetMilliseconds(long ms) { milliseconds_ = ms; }
- inline void SetSeconds(float seconds) { milliseconds_ = static_cast(seconds * 1000.f); }
+ inline void SetSeconds(Float32 seconds) { milliseconds_ = static_cast(seconds * 1000.f); }
- inline void SetMinutes(float minutes) { milliseconds_ = static_cast(minutes * 60 * 1000.f); }
+ inline void SetMinutes(Float32 minutes) { milliseconds_ = static_cast(minutes * 60 * 1000.f); }
- inline void SetHours(float hours) { milliseconds_ = static_cast(hours * 60 * 60 * 1000.f); }
+ inline void SetHours(Float32 hours) { milliseconds_ = static_cast(hours * 60 * 60 * 1000.f); }
// 转为字符串
String ToString() const;
@@ -82,36 +82,36 @@ namespace kiwano
bool operator< (const Duration &) const;
bool operator<= (const Duration &) const;
- float operator / (const Duration &) const;
+ Float32 operator / (const Duration &) const;
const Duration operator + (const Duration &) const;
const Duration operator - (const Duration &) const;
const Duration operator - () const;
- const Duration operator * (int) const;
+ const Duration operator * (Int32) const;
const Duration operator * (unsigned long long) const;
- const Duration operator * (float) const;
- const Duration operator * (double) const;
+ const Duration operator * (Float32) const;
+ const Duration operator * (Float64) const;
const Duration operator * (long double) const;
- const Duration operator / (int) const;
- const Duration operator / (float) const;
- const Duration operator / (double) const;
+ const Duration operator / (Int32) const;
+ const Duration operator / (Float32) const;
+ const Duration operator / (Float64) const;
Duration& operator += (const Duration &);
Duration& operator -= (const Duration &);
- Duration& operator *= (int);
- Duration& operator *= (float);
- Duration& operator *= (double);
- Duration& operator /= (int);
- Duration& operator /= (float);
- Duration& operator /= (double);
+ Duration& operator *= (Int32);
+ Duration& operator *= (Float32);
+ Duration& operator *= (Float64);
+ Duration& operator /= (Int32);
+ Duration& operator /= (Float32);
+ Duration& operator /= (Float64);
- friend const Duration operator* (int, const Duration &);
- friend const Duration operator* (float, const Duration &);
- friend const Duration operator* (double, const Duration &);
+ friend const Duration operator* (Int32, const Duration &);
+ friend const Duration operator* (Float32, const Duration &);
+ friend const Duration operator* (Float64, const Duration &);
friend const Duration operator* (long double, const Duration &);
- friend const Duration operator/ (int, const Duration &);
- friend const Duration operator/ (float, const Duration &);
- friend const Duration operator/ (double, const Duration &);
+ friend const Duration operator/ (Int32, const Duration &);
+ friend const Duration operator/ (Float32, const Duration &);
+ friend const Duration operator/ (Float64, const Duration &);
public:
// 时间段格式化
@@ -154,7 +154,7 @@ namespace kiwano
// 获取当前时间: Time now = Time::Now();
// 两时间相减, 得到一个 Duration 对象, 例如:
// Time t1, t2;
- // int ms = (t2 - t1).Milliseconds(); // 获取两时间相差的毫秒数
+ // Int32 ms = (t2 - t1).Milliseconds(); // 获取两时间相差的毫秒数
//
struct KGE_API Time
{
diff --git a/src/kiwano/base/types.h b/src/kiwano/base/types.h
index b3045ffb..0066700c 100644
--- a/src/kiwano/base/types.h
+++ b/src/kiwano/base/types.h
@@ -19,29 +19,19 @@
// THE SOFTWARE.
#pragma once
-#include "../math/Rect.hpp"
namespace kiwano
{
// 线条样式
- enum class StrokeStyle : int
+ enum class StrokeStyle : Int32
{
Miter = 0, /* 斜切 */
Bevel = 1, /* 斜角 */
Round = 2 /* 圆角 */
};
- // 方向
- enum class Direction : int
- {
- Up, /* 上 */
- Down, /* 下 */
- Left, /* 左 */
- Right /* 右 */
- };
-
// 鼠标指针
- enum class MouseCursor : int
+ enum class MouseCursor : Int32
{
Arrow, /* 指针 */
TextInput, /* 输入文本 */
diff --git a/src/kiwano/core/basic_json.hpp b/src/kiwano/core/basic_json.hpp
index 5579c3a0..5bf68a4a 100644
--- a/src/kiwano/core/basic_json.hpp
+++ b/src/kiwano/core/basic_json.hpp
@@ -19,7 +19,7 @@
// THE SOFTWARE.
#pragma once
-#include
+#include "types.h"
#include
#include
#include
@@ -365,10 +365,10 @@ namespace __json_detail
inline primitive_iterator& operator++() { ++it_; return *this; }
- inline primitive_iterator operator++(int) { primitive_iterator old(it_); ++(*this); return old; }
+ inline primitive_iterator operator++(Int32) { primitive_iterator old(it_); ++(*this); return old; }
inline primitive_iterator& operator--() { --it_; return (*this); }
- inline primitive_iterator operator--(int) { primitive_iterator old = (*this); --(*this); return old; }
+ inline primitive_iterator operator--(Int32) { primitive_iterator old = (*this); --(*this); return old; }
inline bool operator==(primitive_iterator const& other) const { return it_ == other.it_; }
inline bool operator!=(primitive_iterator const& other) const { return !(*this == other); }
@@ -534,7 +534,7 @@ namespace __json_detail
}
}
- inline iterator_impl operator++(int) { iterator_impl old = (*this); ++(*this); return old; }
+ inline iterator_impl operator++(Int32) { iterator_impl old = (*this); ++(*this); return old; }
inline iterator_impl& operator++()
{
check_data();
@@ -560,7 +560,7 @@ namespace __json_detail
return *this;
}
- inline iterator_impl operator--(int) { iterator_impl old = (*this); --(*this); return old; }
+ inline iterator_impl operator--(Int32) { iterator_impl old = (*this); --(*this); return old; }
inline iterator_impl& operator--()
{
check_data();
@@ -732,11 +732,11 @@ namespace __json_detail
using char_traits = ::std::char_traits;
virtual void write(const _CharTy ch) = 0;
- virtual void write(const _CharTy* str, ::std::size_t size) = 0;
+ virtual void write(const _CharTy* str, UInt32 size) = 0;
virtual void write(const _CharTy* str)
{
const auto size = char_traits::length(str);
- write(str, static_cast<::std::size_t>(size));
+ write(str, static_cast(size));
}
};
@@ -755,7 +755,7 @@ namespace __json_detail
str_.push_back(ch);
}
- virtual void write(const char_type* str, ::std::size_t size) override
+ virtual void write(const char_type* str, UInt32 size) override
{
str_.append(str, static_cast(size));
}
@@ -779,7 +779,7 @@ namespace __json_detail
stream_.put(ch);
}
- virtual void write(const char_type* str, ::std::size_t size) override
+ virtual void write(const char_type* str, UInt32 size) override
{
stream_.write(str, static_cast(size));
}
@@ -806,7 +806,7 @@ namespace __json_detail
using array_type = typename _BasicJsonTy::array_type;
using object_type = typename _BasicJsonTy::object_type;
- json_serializer(output_adapter* out, const wchar_t indent_char)
+ json_serializer(output_adapter* out, const WChar indent_char)
: out(out)
, indent_char(indent_char)
, indent_string(32, indent_char)
@@ -816,8 +816,8 @@ namespace __json_detail
void dump(
const _BasicJsonTy& json,
const bool pretty_print,
- const unsigned int indent_step,
- const unsigned int current_indent = 0)
+ const UInt32 indent_step,
+ const UInt32 current_indent = 0)
{
switch (json.type())
{
@@ -843,7 +843,7 @@ namespace __json_detail
auto iter = object.cbegin();
const auto size = object.size();
- for (::std::size_t i = 0; i < size; ++i, ++iter)
+ for (UInt32 i = 0; i < size; ++i, ++iter)
{
out->write(indent_string.c_str(), new_indent);
out->write('\"');
@@ -866,7 +866,7 @@ namespace __json_detail
auto iter = object.cbegin();
const auto size = object.size();
- for (::std::size_t i = 0; i < size; ++i, ++iter)
+ for (UInt32 i = 0; i < size; ++i, ++iter)
{
out->write('\"');
out->write(iter->first.c_str());
@@ -906,7 +906,7 @@ namespace __json_detail
auto iter = vector.cbegin();
const auto size = vector.size();
- for (::std::size_t i = 0; i < size; ++i, ++iter)
+ for (UInt32 i = 0; i < size; ++i, ++iter)
{
out->write(indent_string.c_str(), new_indent);
dump(*iter, true, indent_step, new_indent);
@@ -926,7 +926,7 @@ namespace __json_detail
auto iter = vector.cbegin();
const auto size = vector.size();
- for (::std::size_t i = 0; i < size; ++i, ++iter)
+ for (UInt32 i = 0; i < size; ++i, ++iter)
{
dump(*iter, false, indent_step, current_indent);
// not last element
@@ -999,7 +999,7 @@ namespace __json_detail
do
{
- *(++next) = static_cast('0' + uval % 10);
+ *(++next) = static_cast('0' + uval % 10);
uval /= 10;
} while (uval != 0);
@@ -1085,7 +1085,7 @@ namespace __json_detail
}
else
{
- wchar_t escaped[7] = { 0 };
+ WChar escaped[7] = { 0 };
::swprintf_s(escaped, 7, L"\\u%04x", char_byte);
out->write(escaped);
}
@@ -1205,7 +1205,7 @@ namespace __json_detail
private:
const char_type* str;
- ::std::size_t index;
+ UInt32 index;
};
} // end of namespace __json_detail
@@ -1339,7 +1339,7 @@ namespace __json_detail
token_type scan_literal(const char_type* text, token_type result)
{
- for (::std::size_t i = 0; text[i] != '\0'; ++i)
+ for (UInt32 i = 0; text[i] != '\0'; ++i)
{
if (text[i] != char_traits::to_char_type(current))
{
@@ -1614,10 +1614,10 @@ namespace __json_detail
read_next();
}
- unsigned int exponent = static_cast(current - '0');
+ UInt32 exponent = static_cast(current - '0');
while (::std::isdigit(read_next()))
{
- exponent = (exponent * 10) + static_cast(current - '0');
+ exponent = (exponent * 10) + static_cast(current - '0');
}
float_type power = 1;
@@ -1819,7 +1819,7 @@ namespace __json_detail
template <
typename _IntegerTy,
- typename ::std::enable_if<::std::is_integral<_IntegerTy>::value, int>::type = 0>
+ typename ::std::enable_if<::std::is_integral<_IntegerTy>::value, Int32>::type = 0>
static inline void assign(const _BasicJsonTy& json, _IntegerTy& value)
{
if (!json.is_integer()) throw json_type_error("json value type must be integer");
@@ -1828,16 +1828,16 @@ namespace __json_detail
static inline void assign(const _BasicJsonTy& json, float_type& value)
{
- if (!json.is_float()) throw json_type_error("json value type must be float");
+ if (!json.is_float()) throw json_type_error("json value type must be Float32");
value = json.value_.data.number_float;
}
template <
typename _FloatingTy,
- typename ::std::enable_if<::std::is_floating_point<_FloatingTy>::value, int>::type = 0>
+ typename ::std::enable_if<::std::is_floating_point<_FloatingTy>::value, Int32>::type = 0>
static inline void assign(const _BasicJsonTy& json, _FloatingTy& value)
{
- if (!json.is_float()) throw json_type_error("json value type must be float");
+ if (!json.is_float()) throw json_type_error("json value type must be Float32");
value = static_cast<_FloatingTy>(json.value_.data.number_float);
}
};
@@ -1859,7 +1859,7 @@ class basic_json
public:
template
using allocator_type = _Allocator<_Ty>;
- using size_type = ::std::size_t;
+ using size_type = UInt32;
using difference_type = ::std::ptrdiff_t;
using string_type = _StringTy;
using char_type = typename _StringTy::value_type;
@@ -1895,7 +1895,7 @@ public:
template <
typename _CompatibleTy,
- typename ::std::enable_if<::std::is_constructible::value, int>::type = 0>
+ typename ::std::enable_if<::std::is_constructible::value, Int32>::type = 0>
basic_json(const _CompatibleTy& value)
{
value_.type = JsonType::String;
@@ -1919,7 +1919,7 @@ public:
template <
typename _IntegerTy,
- typename ::std::enable_if<::std::is_integral<_IntegerTy>::value, int>::type = 0>
+ typename ::std::enable_if<::std::is_integral<_IntegerTy>::value, Int32>::type = 0>
basic_json(_IntegerTy value)
: value_(static_cast(value))
{
@@ -1932,7 +1932,7 @@ public:
template <
typename _FloatingTy,
- typename ::std::enable_if<::std::is_floating_point<_FloatingTy>::value, int>::type = 0>
+ typename ::std::enable_if<::std::is_floating_point<_FloatingTy>::value, Int32>::type = 0>
basic_json(_FloatingTy value)
: value_(static_cast(value))
{
@@ -2027,7 +2027,7 @@ public:
case JsonType::Integer:
return string_type(L"integer");
case JsonType::Float:
- return string_type(L"float");
+ return string_type(L"Float32");
case JsonType::Boolean:
return string_type(L"boolean");
case JsonType::Null:
@@ -2123,7 +2123,7 @@ public:
class _IteratorTy,
typename ::std::enable_if<
::std::is_same<_IteratorTy, iterator>::value ||
- ::std::is_same<_IteratorTy, const_iterator>::value, int
+ ::std::is_same<_IteratorTy, const_iterator>::value, Int32
>::type = 0>
inline _IteratorTy erase(_IteratorTy pos)
{
@@ -2154,7 +2154,7 @@ public:
class _IteratorTy,
typename ::std::enable_if<
::std::is_same<_IteratorTy, iterator>::value ||
- ::std::is_same<_IteratorTy, const_iterator>::value, int
+ ::std::is_same<_IteratorTy, const_iterator>::value, Int32
>::type = 0>
inline _IteratorTy erase(_IteratorTy first, _IteratorTy last)
{
@@ -2282,7 +2282,7 @@ public:
template <
typename _IntegerTy,
- typename ::std::enable_if<::std::is_integral<_IntegerTy>::value, int>::type = 0>
+ typename ::std::enable_if<::std::is_integral<_IntegerTy>::value, Int32>::type = 0>
inline bool get_value(_IntegerTy& val) const
{
if (is_integer())
@@ -2295,7 +2295,7 @@ public:
template <
typename _FloatingTy,
- typename ::std::enable_if<::std::is_floating_point<_FloatingTy>::value, int>::type = 0>
+ typename ::std::enable_if<::std::is_floating_point<_FloatingTy>::value, Int32>::type = 0>
inline bool get_value(_FloatingTy& val) const
{
if (is_float())
@@ -2350,7 +2350,7 @@ public:
float_type as_float() const
{
- if (!is_float()) throw json_type_error("json value must be float");
+ if (!is_float()) throw json_type_error("json value must be Float32");
return value_.data.number_float;
}
@@ -2545,12 +2545,12 @@ public:
out.width(0);
__json_detail::stream_output_adapter adapter(out);
- __json_detail::json_serializer(&adapter, out.fill()).dump(json, pretty_print, static_cast(indentation));
+ __json_detail::json_serializer(&adapter, out.fill()).dump(json, pretty_print, static_cast(indentation));
return out;
}
string_type dump(
- const int indent = -1,
+ const Int32 indent = -1,
const char_type indent_char = ' ') const
{
string_type result;
@@ -2561,12 +2561,12 @@ public:
void dump(
__json_detail::output_adapter* adapter,
- const int indent = -1,
+ const Int32 indent = -1,
const char_type indent_char = ' ') const
{
if (indent >= 0)
{
- __json_detail::json_serializer(adapter, indent_char).dump(*this, true, static_cast(indent));
+ __json_detail::json_serializer(adapter, indent_char).dump(*this, true, static_cast(indent));
}
else
{
diff --git a/src/kiwano/core/core.h b/src/kiwano/core/core.h
index 418ddcaf..ea5f63d8 100644
--- a/src/kiwano/core/core.h
+++ b/src/kiwano/core/core.h
@@ -25,7 +25,7 @@
#include "intrusive_ptr.hpp"
#include "noncopyable.hpp"
#include "singleton.hpp"
-#include "Function.hpp"
+#include "function.hpp"
#include "basic_json.hpp"
#include
#include