[deploy] Add numeric types alias

This commit is contained in:
Nomango 2019-08-18 22:49:44 +08:00
parent dab2f2c112
commit 90c0bcc3b0
121 changed files with 1125 additions and 1058 deletions

View File

@ -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:

View File

@ -75,7 +75,7 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<TreatWarningAsError>true</TreatWarningAsError>
<DebugInformationFormat>None</DebugInformationFormat>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>../src/</AdditionalIncludeDirectories>
<MinimalRebuild>false</MinimalRebuild>
@ -93,7 +93,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<BufferSecurityCheck>false</BufferSecurityCheck>
<TreatWarningAsError>true</TreatWarningAsError>
<DebugInformationFormat>None</DebugInformationFormat>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>../src/</AdditionalIncludeDirectories>
<MinimalRebuild>false</MinimalRebuild>

View File

@ -84,7 +84,7 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<TreatWarningAsError>true</TreatWarningAsError>
<DebugInformationFormat>None</DebugInformationFormat>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>../src/</AdditionalIncludeDirectories>
<MinimalRebuild>false</MinimalRebuild>
@ -102,7 +102,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<BufferSecurityCheck>false</BufferSecurityCheck>
<TreatWarningAsError>true</TreatWarningAsError>
<DebugInformationFormat>None</DebugInformationFormat>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>../src/</AdditionalIncludeDirectories>
<MinimalRebuild>false</MinimalRebuild>

View File

@ -73,7 +73,7 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<TreatWarningAsError>true</TreatWarningAsError>
<DebugInformationFormat>None</DebugInformationFormat>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>../src/</AdditionalIncludeDirectories>
<MinimalRebuild>false</MinimalRebuild>
@ -91,7 +91,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<BufferSecurityCheck>false</BufferSecurityCheck>
<TreatWarningAsError>true</TreatWarningAsError>
<DebugInformationFormat>None</DebugInformationFormat>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>../src/</AdditionalIncludeDirectories>
<MinimalRebuild>false</MinimalRebuild>

View File

@ -21,6 +21,7 @@
<ClInclude Include="..\src\kiwano\core\noncopyable.hpp" />
<ClInclude Include="..\src\kiwano\core\singleton.hpp" />
<ClInclude Include="..\src\kiwano\core\string.hpp" />
<ClInclude Include="..\src\kiwano\core\types.h" />
<ClInclude Include="..\src\kiwano\core\vector.hpp" />
<ClInclude Include="..\src\kiwano\kiwano.h" />
<ClInclude Include="..\src\kiwano\config.h" />

View File

@ -306,6 +306,9 @@
<ClInclude Include="..\src\kiwano\renderer\FontCollection.h">
<Filter>renderer</Filter>
</ClInclude>
<ClInclude Include="..\src\kiwano\core\types.h">
<Filter>core</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\kiwano\ui\Button.cpp">

View File

@ -0,0 +1,8 @@
$replace = "<DebugInformationFormat>EditAndContinue</DebugInformationFormat>"
$replaceTo = "<DebugInformationFormat>None</DebugInformationFormat>"
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
}

View File

@ -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_)

View File

@ -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;
// <20>零稜좆
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<size_t, SoundPtr>;
using MusicMap = Map<UInt32, SoundPtr>;
MusicMap sound_cache_;
};
}

View File

@ -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<UINT32>(loop_count);
buffer.LoopCount = static_cast<UInt32>(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");

View File

@ -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_;
};

View File

@ -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<const BYTE*>(data.buffer),
static_cast<UINT>(data.size)
static_cast<UInt32>(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_,

View File

@ -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:

View File

@ -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**);

View File

@ -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

View File

@ -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();

View File

@ -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<std::codecvt_utf8<wchar_t>> utf8_conv;
std::wstring_convert<std::codecvt_utf8<WChar>> utf8_conv;
kiwano::string result;
try
@ -66,7 +66,7 @@ namespace
kiwano::wstring convert_from_utf8(kiwano::string const& str)
{
kiwano::string_convert<std::codecvt_utf8<wchar_t>> utf8_conv;
kiwano::string_convert<std::codecvt_utf8<WChar>> 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));
}
}

View File

@ -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<ActorPtr> Actor::GetChildren(String const& name) const
{
Vector<ActorPtr> children;
size_t hash_code = std::hash<String>{}(name);
UInt32 hash_code = std::hash<String>{}(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<String>{}(name);
UInt32 hash_code = std::hash<String>{}(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<String>{}(child_name);
UInt32 hash_code = std::hash<String>{}(child_name);
Actor* next;
for (Actor* child = children_.first_item().get(); child; child = next)

View File

@ -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_;

View File

@ -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);
}

View File

@ -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_;

View File

@ -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; }

View File

@ -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];

View File

@ -47,7 +47,7 @@ namespace kiwano
);
// 获取关键帧
FramePtr GetFrame(size_t index) const;
FramePtr GetFrame(UInt32 index) const;
// 获取关键帧
Vector<FramePtr> const& GetFrames() const;

View File

@ -73,8 +73,8 @@ namespace kiwano
disposal_type_ = DisposalType::None;
SetSize(
static_cast<float>(image_.GetWidthInPixels()),
static_cast<float>(image_.GetHeightInPixels())
static_cast<Float32>(image_.GetWidthInPixels()),
static_cast<Float32>(image_.GetHeightInPixels())
);
if (!frame_rt_.IsValid())

View File

@ -32,7 +32,7 @@ namespace kiwano
{
public:
using DisposalType = GifImage::DisposalType;
using LoopDoneCallback = Function<void(int)>;
using LoopDoneCallback = Function<void(Int32)>;
using DoneCallback = Function<void()>;
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_;

View File

@ -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);

View File

@ -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) {}
// ÍÌûÏûÏ¢

View File

@ -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);
}

View File

@ -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° 的弧 */
);

View File

@ -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;
}

View File

@ -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
);
// 设置描边线相交样式

View File

@ -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)

View File

@ -26,7 +26,7 @@ namespace kiwano
class Transform
{
public:
float rotation; // Ðýת
Float32 rotation; // Ðýת
Point position; // ×ø±ê
Point scale; // Ëõ·Å
Point skew; // ´íÇнǶÈ

View File

@ -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)
{

View File

@ -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,7 +156,7 @@ namespace kiwano
void Reset() override;
protected:
Direction direction_;
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_;
};
}

View File

@ -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_;

View File

@ -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));
}

View File

@ -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)

View File

@ -29,7 +29,7 @@ namespace kiwano
public:
// 添加动作
ActionPtr AddAction(
Action* AddAction(
ActionPtr action
);

View File

@ -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<int>(loops_done))
while (loops_done_ < static_cast<Int32>(loops_done))
{
Complete(target); // loops_done_++
}
percent = (status_ == Status::Done) ? 1.f : (loops_done - static_cast<float>(loops_done_));
percent = (status_ == Status::Done) ? 1.f : (loops_done - static_cast<Float32>(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);

View File

@ -25,7 +25,7 @@
namespace kiwano
{
// 缓动函数
using EaseFunc = Function<float(float)>;
using EaseFunc = Function<Float32(Float32)>;
// 缓动函数枚举
// 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<void(ActorPtr, float)>;
using TweenFunc = Function<void(ActorPtr, Float32)>;
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_;

View File

@ -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);
}

View File

@ -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_;

View File

@ -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<Sprite*>(target.get());
@ -73,7 +73,7 @@ namespace kiwano
const auto& frames = frame_seq_->GetFrames();
auto size = frames.size();
auto index = std::min(static_cast<size_t>(math::Floor(size * percent)), size - 1);
auto index = std::min(static_cast<UInt32>(math::Floor(size * percent)), size - 1);
sprite_target->SetFrame(frames[index]);
}

View File

@ -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_;

View File

@ -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()

View File

@ -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) {}
};
}

View File

@ -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;
}

View File

@ -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)

View File

@ -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);

View File

@ -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)

View File

@ -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_;
};
}

View File

@ -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<float>(GET_X_LPARAM(lparam)), static_cast<float>(GET_Y_LPARAM(lparam))); }
else if (msg == WM_MOUSEMOVE) { UpdateMousePos(static_cast<Float32>(GET_X_LPARAM(lparam)), static_cast<Float32>(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);
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);
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);
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_;
}

View File

@ -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_;
};
}

View File

@ -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;

View File

@ -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 <typename ..._Args>
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 <typename ..._Args>
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 <typename ..._Args>
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 <typename ..._Args>
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 <typename ..._Args>
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 <typename ..._Args>
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 <typename ..._Args>
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<int>{((ss << ' ' << args), 0)...};
(void)std::initializer_list<Int32>{((ss << ' ' << args), 0)...};
return ss.str();
}

View File

@ -30,7 +30,7 @@ namespace kiwano
Vector<ObjectBase*> tracing_objects;
}
unsigned int ObjectBase::last_object_id = 0;
UInt32 ObjectBase::last_object_id = 0;
ObjectBase::ObjectBase()
: tracing_leak_(false)

View File

@ -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;
};
}

View File

@ -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<void*>(buffer);
data_.size = static_cast<UINT32>(size);
data_.size = static_cast<UInt32>(size);
} while (0);
return data_;

View File

@ -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_;
};

View File

@ -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)

View File

@ -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_;

View File

@ -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<float>(width_),
static_cast<float>(height_)
static_cast<Float32>(width_),
static_cast<Float32>(height_)
};
}
float Window::GetWidth() const
Float32 Window::GetWidth() const
{
return static_cast<float>(width_);
return static_cast<Float32>(width_);
}
float Window::GetHeight() const
Float32 Window::GetHeight() const
{
return static_cast<float>(height_);
return static_cast<Float32>(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;

View File

@ -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_;
};

View File

@ -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
{

View File

@ -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<float>(sec) + static_cast<float>(ms) / 1000.f;
return static_cast<Float32>(sec) + static_cast<Float32>(ms) / 1000.f;
}
float Duration::Minutes() const
Float32 Duration::Minutes() const
{
long min = milliseconds_ / Min.milliseconds_;
long ms = milliseconds_ % Min.milliseconds_;
return static_cast<float>(min) + static_cast<float>(ms) / (60 * 1000.f);
return static_cast<Float32>(min) + static_cast<Float32>(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<float>(hour) + static_cast<float>(ms) / (60 * 60 * 1000.f);
return static_cast<Float32>(hour) + static_cast<Float32>(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<float>(sec) + static_cast<float>(ms) / 1000.f))
result.append(float_to_str(static_cast<Float32>(sec) + static_cast<Float32>(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<float>(milliseconds_) / other.milliseconds_;
return static_cast<Float32>(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<long>(milliseconds_ * val));
}
const Duration Duration::operator*(float val) const
const Duration Duration::operator*(Float32 val) const
{
return Duration(static_cast<long>(milliseconds_ * val));
}
const Duration Duration::operator*(double val) const
const Duration Duration::operator*(Float64 val) const
{
return Duration(static_cast<long>(milliseconds_ * val));
}
@ -264,17 +264,17 @@ namespace kiwano
return Duration(static_cast<long>(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<long>(milliseconds_ / val));
}
const Duration Duration::operator/(double val) const
const Duration Duration::operator/(Float64 val) const
{
return Duration(static_cast<long>(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<long>(milliseconds_ / val);
return (*this);
}
Duration & Duration::operator*=(float val)
Duration & Duration::operator*=(Float32 val)
{
milliseconds_ = static_cast<long>(milliseconds_ * val);
return (*this);
}
Duration & Duration::operator/=(float val)
Duration & Duration::operator/=(Float32 val)
{
milliseconds_ = static_cast<long>(milliseconds_ / val);
return (*this);
}
Duration & Duration::operator*=(double val)
Duration & Duration::operator*=(Float64 val)
{
milliseconds_ = static_cast<long>(milliseconds_ * val);
return (*this);
}
Duration & Duration::operator/=(double val)
Duration & Duration::operator/=(Float64 val)
{
milliseconds_ = static_cast<long>(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;
}

View File

@ -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<long>(seconds * 1000.f); }
inline void SetSeconds(Float32 seconds) { milliseconds_ = static_cast<long>(seconds * 1000.f); }
inline void SetMinutes(float minutes) { milliseconds_ = static_cast<long>(minutes * 60 * 1000.f); }
inline void SetMinutes(Float32 minutes) { milliseconds_ = static_cast<long>(minutes * 60 * 1000.f); }
inline void SetHours(float hours) { milliseconds_ = static_cast<long>(hours * 60 * 60 * 1000.f); }
inline void SetHours(Float32 hours) { milliseconds_ = static_cast<long>(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
{

View File

@ -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, /* 输入文本 */

View File

@ -19,7 +19,7 @@
// THE SOFTWARE.
#pragma once
#include <cstdint>
#include "types.h"
#include <cctype>
#include <memory>
#include <array>
@ -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<char_type>;
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<UInt32>(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_type>(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_type>(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<char_type>* out, const wchar_t indent_char)
json_serializer(output_adapter<char_type>* 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<wchar_t>('0' + uval % 10);
*(++next) = static_cast<WChar>('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<unsigned int>(current - '0');
UInt32 exponent = static_cast<UInt32>(current - '0');
while (::std::isdigit(read_next()))
{
exponent = (exponent * 10) + static_cast<unsigned int>(current - '0');
exponent = (exponent * 10) + static_cast<UInt32>(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 <typename _Ty>
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<string_type, _CompatibleTy>::value, int>::type = 0>
typename ::std::enable_if<::std::is_constructible<string_type, _CompatibleTy>::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<integer_type>(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<float_type>(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<char_type> adapter(out);
__json_detail::json_serializer<basic_json>(&adapter, out.fill()).dump(json, pretty_print, static_cast<unsigned int>(indentation));
__json_detail::json_serializer<basic_json>(&adapter, out.fill()).dump(json, pretty_print, static_cast<UInt32>(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<char_type>* adapter,
const int indent = -1,
const Int32 indent = -1,
const char_type indent_char = ' ') const
{
if (indent >= 0)
{
__json_detail::json_serializer<basic_json>(adapter, indent_char).dump(*this, true, static_cast<unsigned int>(indent));
__json_detail::json_serializer<basic_json>(adapter, indent_char).dump(*this, true, static_cast<UInt32>(indent));
}
else
{

View File

@ -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 <set>
#include <map>
@ -68,7 +68,7 @@ namespace kiwano
using Function = kiwano::core::function<_FuncTy>;
using Json = kiwano::core::basic_json<kiwano::Map, kiwano::Vector, kiwano::String,
std::int32_t, double, bool, std::allocator>;
Int32, Float64, bool, std::allocator>;
}
namespace std

View File

@ -42,7 +42,7 @@ namespace __function_detail
template <typename _Ty, typename _Ret, typename... _Args>
struct helper
{
template <typename _Uty> static int test(...);
template <typename _Uty> static Int32 test(...);
template <typename _Uty, _Ret(_Uty::*)(_Args...)> struct class_mem;
template <typename _Uty> static char test(class_mem<_Uty, &_Uty::operator()>*);
@ -54,7 +54,7 @@ namespace __function_detail
typename _Uty,
typename _Uret = typename ::std::decay<decltype(::std::declval<_Uty>().operator()(::std::declval<_Args>()...))>::type,
typename = typename ::std::enable_if<::std::is_convertible<_Ret, _Uret>::value>::type>
static char test(int);
static char test(Int32);
static constexpr bool value = sizeof(test<_Ty>(0)) == sizeof(char);
};
@ -76,9 +76,9 @@ namespace __function_detail
public:
virtual ~callable() {}
virtual void AddRef() = 0;
virtual void Release() = 0;
virtual _Ret Invoke(_Args... args) const = 0;
virtual void retain() = 0;
virtual void release() = 0;
virtual _Ret invoke(_Args... args) const = 0;
};
template<typename _Ret, typename... _Args>
@ -88,12 +88,12 @@ namespace __function_detail
public:
ref_count_callable() : ref_count_(0) {}
virtual void AddRef() override
virtual void retain() override
{
++ref_count_;
}
virtual void Release() override
virtual void release() override
{
--ref_count_;
if (ref_count_ <= 0)
@ -103,7 +103,7 @@ namespace __function_detail
}
private:
int ref_count_;
Int32 ref_count_;
};
template<typename _Ty, typename _Ret, typename... _Args>
@ -116,12 +116,12 @@ namespace __function_detail
{
}
virtual _Ret Invoke(_Args... args) const override
virtual _Ret invoke(_Args... args) const override
{
return callee_(::std::forward<_Args&&>(args)...);
}
static inline callable<_Ret, _Args...>* Make(_Ty&& val)
static inline callable<_Ret, _Args...>* make(_Ty&& val)
{
return new (::std::nothrow) proxy_callable<_Ty, _Ret, _Args...>(::std::move(val));
}
@ -137,12 +137,12 @@ namespace __function_detail
public:
typedef _Ret(_Ty::* _FuncType)(_Args...);
virtual _Ret Invoke(_Args... args) const override
virtual _Ret invoke(_Args... args) const override
{
return (static_cast<_Ty*>(ptr_)->*func_)(::std::forward<_Args>(args)...);
}
static inline callable<_Ret, _Args...>* Make(void* ptr, _FuncType func)
static inline callable<_Ret, _Args...>* make(void* ptr, _FuncType func)
{
return new (::std::nothrow) proxy_mem_callable<_Ty, _Ret, _Args...>(ptr, func);
}
@ -166,12 +166,12 @@ namespace __function_detail
public:
typedef _Ret(_Ty::* _FuncType)(_Args...) const;
virtual _Ret Invoke(_Args... args) const override
virtual _Ret invoke(_Args... args) const override
{
return (static_cast<_Ty*>(ptr_)->*func_)(::std::forward<_Args>(args)...);
}
static inline callable<_Ret, _Args...>* Make(void* ptr, _FuncType func)
static inline callable<_Ret, _Args...>* make(void* ptr, _FuncType func)
{
return new (::std::nothrow) proxy_const_mem_callable<_Ty, _Ret, _Args...>(ptr, func);
}
@ -227,7 +227,7 @@ public:
function(const function& rhs)
: callable_(rhs.callable_)
{
if (callable_) callable_->AddRef();
if (callable_) callable_->retain();
}
function(function&& rhs) noexcept
@ -238,35 +238,35 @@ public:
function(_Ret(*func)(_Args...))
{
callable_ = __function_detail::proxy_callable<_Ret(*)(_Args...), _Ret, _Args...>::Make(::std::move(func));
if (callable_) callable_->AddRef();
callable_ = __function_detail::proxy_callable<_Ret(*)(_Args...), _Ret, _Args...>::make(::std::move(func));
if (callable_) callable_->retain();
}
template<
typename _Ty,
typename = typename ::std::enable_if<__function_detail::is_callable<_Ty, _Ret, _Args...>::value, int>::type>
typename = typename ::std::enable_if<__function_detail::is_callable<_Ty, _Ret, _Args...>::value, Int32>::type>
function(_Ty val)
{
callable_ = __function_detail::proxy_callable<_Ty, _Ret, _Args...>::Make(::std::move(val));
if (callable_) callable_->AddRef();
callable_ = __function_detail::proxy_callable<_Ty, _Ret, _Args...>::make(::std::move(val));
if (callable_) callable_->retain();
}
template<typename _Ty,
typename _Uty,
typename = typename ::std::enable_if<::std::is_same<_Ty, _Uty>::value || ::std::is_base_of<_Ty, _Uty>::value, int>::type>
typename = typename ::std::enable_if<::std::is_same<_Ty, _Uty>::value || ::std::is_base_of<_Ty, _Uty>::value, Int32>::type>
function(_Uty* ptr, _Ret(_Ty::* func)(_Args...))
{
callable_ = __function_detail::proxy_mem_callable<_Ty, _Ret, _Args...>::Make(ptr, func);
if (callable_) callable_->AddRef();
callable_ = __function_detail::proxy_mem_callable<_Ty, _Ret, _Args...>::make(ptr, func);
if (callable_) callable_->retain();
}
template<typename _Ty,
typename _Uty,
typename = typename ::std::enable_if<::std::is_same<_Ty, _Uty>::value || ::std::is_base_of<_Ty, _Uty>::value, int>::type>
typename = typename ::std::enable_if<::std::is_same<_Ty, _Uty>::value || ::std::is_base_of<_Ty, _Uty>::value, Int32>::type>
function(_Uty* ptr, _Ret(_Ty::* func)(_Args...) const)
{
callable_ = __function_detail::proxy_const_mem_callable<_Ty, _Ret, _Args...>::Make(ptr, func);
if (callable_) callable_->AddRef();
callable_ = __function_detail::proxy_const_mem_callable<_Ty, _Ret, _Args...>::make(ptr, func);
if (callable_) callable_->retain();
}
~function()
@ -283,7 +283,7 @@ public:
{
if (!callable_)
throw bad_function_call();
return callable_->Invoke(::std::forward<_Args>(args)...);
return callable_->invoke(::std::forward<_Args>(args)...);
}
inline operator bool() const
@ -295,7 +295,7 @@ public:
{
tidy();
callable_ = rhs.callable_;
if (callable_) callable_->AddRef();
if (callable_) callable_->retain();
return (*this);
}
@ -312,7 +312,7 @@ private:
{
if (callable_)
{
callable_->Release();
callable_->release();
callable_ = nullptr;
}
}
@ -330,11 +330,11 @@ namespace kiwano
template<typename _Ty,
typename _Uty,
typename = typename std::enable_if<
std::is_same<_Ty, _Uty>::value || std::is_base_of<_Ty, _Uty>::value, int
std::is_same<_Ty, _Uty>::value || std::is_base_of<_Ty, _Uty>::value, Int32
>::type,
typename _Ret,
typename... _Args>
inline function<_Ret(_Args...)> bind_func(_Uty* ptr, _Ret(_Ty::* func)(_Args...))
inline function<_Ret(_Args...)> Closure(_Uty* ptr, _Ret(_Ty::* func)(_Args...))
{
return function<_Ret(_Args...)>(ptr, func);
}
@ -342,11 +342,11 @@ namespace kiwano
template<typename _Ty,
typename _Uty,
typename = typename std::enable_if<
std::is_same<_Ty, _Uty>::value || std::is_base_of<_Ty, _Uty>::value, int
std::is_same<_Ty, _Uty>::value || std::is_base_of<_Ty, _Uty>::value, Int32
>::type,
typename _Ret,
typename... _Args>
inline function<_Ret(_Args...)> bind_func(_Uty* ptr, _Ret(_Ty::* func)(_Args...) const)
inline function<_Ret(_Args...)> Closure(_Uty* ptr, _Ret(_Ty::* func)(_Args...) const)
{
return function<_Ret(_Args...)>(ptr, func);
}

View File

@ -20,6 +20,7 @@
#pragma once
#include "../macros.h"
#include "types.h"
// #define KGE_DEBUG_ENABLE_LIST_CHECK
@ -230,7 +231,7 @@ private:
if (!first_)
return;
int pos = 0;
Int32 pos = 0;
T p = first_;
T tmp = p;
do

View File

@ -19,6 +19,7 @@
// THE SOFTWARE.
#pragma once
#include "types.h"
#include <string>
#include <algorithm>
#include <codecvt>
@ -35,7 +36,7 @@ inline namespace core
//
// basic_string<>
// Lightweight ::std::basic_string<>-like class
// When using basic_string<> with a c-style string (char* or wchar_t*), constructor and operator=() just hold
// When using basic_string<> with a c-style string (char* or WChar*), constructor and operator=() just hold
// a pointer to the character array but don't copy its content, considering performance issues.
// Use assign() and basic_string<>::cstr() to work fine with c-style strings.
//
@ -62,10 +63,10 @@ public:
inline pointer base() const { return base_; }
inline iterator_impl& operator++() { ++base_; 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--() { --base_; 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 const iterator_impl operator+(difference_type off) const { return iterator_impl(base_ + off); }
inline const iterator_impl operator-(difference_type off) const { return iterator_impl(base_ - off); }
@ -95,7 +96,7 @@ public:
public:
using value_type = _CharTy;
using char_type = value_type;
using size_type = size_t;
using size_type = UInt32;
using reference = value_type &;
using const_reference = const value_type &;
using iterator = iterator_impl<value_type>;
@ -120,7 +121,7 @@ public:
inline const char_type* c_str() const { return empty() ? empty_cstr : const_str_; }
inline const char_type* data() const { return empty() ? empty_cstr : const_str_; }
inline char_type at(size_t i) const { return (*this)[i]; }
inline char_type at(UInt32 i) const { return (*this)[i]; }
inline size_type size() const { return size_; }
inline size_type length() const { return size(); }
inline size_type capacity() const { return capacity_; }
@ -131,8 +132,8 @@ public:
void reserve(const size_type new_cap = 0);
inline void resize(const size_type new_size, const char_type ch = value_type()) { check_operability(); if (new_size < size_) str_[size_ = new_size] = value_type(); else append(new_size - size_, ch); }
int compare(const char_type* const str) const;
inline int compare(basic_string const& str) const { return compare(str.c_str()); }
Int32 compare(const char_type* const str) const;
inline Int32 compare(basic_string const& str) const { return compare(str.c_str()); }
basic_string& append(size_type count, char_type ch);
basic_string& append(const char_type* cstr, size_type count);
@ -195,17 +196,17 @@ public:
size_type copy(char_type* cstr, size_type count, size_type pos = 0) const;
void swap(basic_string& rhs) noexcept;
size_t hash() const;
UInt32 hash() const;
public:
static basic_string parse(int val);
static basic_string parse(unsigned int val);
static basic_string parse(Int32 val);
static basic_string parse(UInt32 val);
static basic_string parse(long val);
static basic_string parse(unsigned long val);
static basic_string parse(long long val);
static basic_string parse(unsigned long long val);
static basic_string parse(float val);
static basic_string parse(double val);
static basic_string parse(Float32 val);
static basic_string parse(Float64 val);
static basic_string parse(long double val);
template <typename ..._Args>
@ -384,10 +385,10 @@ template <typename _CharTy>
//
template <typename _CharTy>
basic_string<_CharTy> to_basic_string(int val);
basic_string<_CharTy> to_basic_string(Int32 val);
template <typename _CharTy>
basic_string<_CharTy> to_basic_string(unsigned int val);
basic_string<_CharTy> to_basic_string(UInt32 val);
template <typename _CharTy>
basic_string<_CharTy> to_basic_string(long val);
@ -402,10 +403,10 @@ template <typename _CharTy>
basic_string<_CharTy> to_basic_string(unsigned long long val);
template <typename _CharTy>
basic_string<_CharTy> to_basic_string(float val);
basic_string<_CharTy> to_basic_string(Float32 val);
template <typename _CharTy>
basic_string<_CharTy> to_basic_string(double val);
basic_string<_CharTy> to_basic_string(Float64 val);
template <typename _CharTy>
basic_string<_CharTy> to_basic_string(long double val);
@ -418,14 +419,14 @@ template <typename ..._Args>
basic_string<char> format_string(const char* const fmt, _Args&&... args);
template <typename ..._Args>
basic_string<wchar_t> format_string(const wchar_t* const fmt, _Args&& ... args);
basic_string<WChar> format_string(const WChar* const fmt, _Args&& ... args);
//
// string && wstring
//
using string = ::kiwano::core::basic_string<char>;
using wstring = ::kiwano::core::basic_string<wchar_t>;
using wstring = ::kiwano::core::basic_string<WChar>;
} // inline namespace core
} // namespace kiwano
@ -439,13 +440,13 @@ namespace kiwano
namespace __string_details
{
template<class _Traits>
size_t TraitsFind(
const typename _Traits::char_type* first, size_t first_size, size_t offset,
const typename _Traits::char_type* second, size_t count)
UInt32 TraitsFind(
const typename _Traits::char_type* first, UInt32 first_size, UInt32 offset,
const typename _Traits::char_type* second, UInt32 count)
{
if (count > first_size || offset > first_size - count)
{
return static_cast<size_t>(-1);
return static_cast<UInt32>(-1);
}
if (count == 0)
@ -456,23 +457,23 @@ namespace __string_details
const auto matches_end = first + (first_size - count) + 1;
for (auto iter = first + offset; ; ++iter)
{
iter = typename _Traits::find(iter, static_cast<size_t>(matches_end - iter), *second);
iter = typename _Traits::find(iter, static_cast<UInt32>(matches_end - iter), *second);
if (!iter)
{
return static_cast<size_t>(-1);
return static_cast<UInt32>(-1);
}
if (typename _Traits::compare(iter, second, count) == 0)
{
return static_cast<size_t>(iter - first);
return static_cast<UInt32>(iter - first);
}
}
}
template<class _Traits>
size_t TraitsFindLastOf(
const typename _Traits::char_type* first, const size_t first_size, const size_t pos,
const typename _Traits::char_type* second, const size_t count)
UInt32 TraitsFindLastOf(
const typename _Traits::char_type* first, const UInt32 first_size, const UInt32 pos,
const typename _Traits::char_type* second, const UInt32 count)
{
if (count != 0 && first_size != 0)
{
@ -480,7 +481,7 @@ namespace __string_details
{
if (typename _Traits::find(second, count, *iter))
{
return static_cast<size_t>(iter - first);
return static_cast<UInt32>(iter - first);
}
if (iter == first)
{
@ -488,7 +489,7 @@ namespace __string_details
}
}
}
return static_cast<size_t>(-1);
return static_cast<UInt32>(-1);
}
}
@ -592,7 +593,7 @@ inline namespace core
size_ = count;
traits_type::assign(str_, size_, ch);
traits_type::assign(str_[size_], value_type());
traits_type::assign(*(str_ + size_), value_type());
}
else
{
@ -805,8 +806,8 @@ inline namespace core
{
check_operability();
size_t new_size = size_ + count;
size_t new_cap = new_size + 1;
UInt32 new_size = size_ + count;
UInt32 new_cap = new_size + 1;
char_type* new_str = allocate(new_cap);
traits_type::move(new_str, str_, size_);
@ -826,8 +827,8 @@ inline namespace core
{
check_operability();
size_t new_size = size_ + count;
size_t new_cap = new_size + 1;
UInt32 new_size = size_ + count;
UInt32 new_cap = new_size + 1;
char_type* new_str = allocate(new_cap);
traits_type::move(new_str, str_, size_);
@ -852,8 +853,8 @@ inline namespace core
count = other.clamp_suffix_size(pos, count);
size_t new_size = size_ + count;
size_t new_cap = new_size + 1;
UInt32 new_size = size_ + count;
UInt32 new_cap = new_size + 1;
char_type* new_str = allocate(new_cap);
traits_type::move(new_str, str_, size_);
@ -886,27 +887,27 @@ inline namespace core
}
template <typename _CharTy>
inline size_t basic_string<_CharTy>::hash() const
inline UInt32 basic_string<_CharTy>::hash() const
{
static size_t fnv_prime = 16777619U;
size_t fnv_offset_basis = 2166136261U;
static UInt32 fnv_prime = 16777619U;
UInt32 fnv_offset_basis = 2166136261U;
for (size_t index = 0; index < size_; ++index)
for (UInt32 index = 0; index < size_; ++index)
{
fnv_offset_basis ^= static_cast<size_t>(const_str_[index]);
fnv_offset_basis ^= static_cast<UInt32>(const_str_[index]);
fnv_offset_basis *= fnv_prime;
}
return fnv_offset_basis;
}
template <typename _CharTy>
inline int basic_string<_CharTy>::compare(const char_type* const str) const
inline Int32 basic_string<_CharTy>::compare(const char_type* const str) const
{
size_type count1 = size();
size_type count2 = traits_type::length(str);
size_type rlen = ::std::min(count1, count2);
int ret = traits_type::compare(const_str_, str, rlen);
Int32 ret = traits_type::compare(const_str_, str, rlen);
if (ret != 0)
return ret;
@ -1136,10 +1137,10 @@ inline namespace core
//
template <typename _CharTy>
inline basic_string<_CharTy> basic_string<_CharTy>::parse(int val) { return ::kiwano::to_basic_string<char_type>(val); }
inline basic_string<_CharTy> basic_string<_CharTy>::parse(Int32 val) { return ::kiwano::to_basic_string<char_type>(val); }
template <typename _CharTy>
inline basic_string<_CharTy> basic_string<_CharTy>::parse(unsigned int val) { return ::kiwano::to_basic_string<char_type>(val); }
inline basic_string<_CharTy> basic_string<_CharTy>::parse(UInt32 val) { return ::kiwano::to_basic_string<char_type>(val); }
template <typename _CharTy>
inline basic_string<_CharTy> basic_string<_CharTy>::parse(long val) { return ::kiwano::to_basic_string<char_type>(val); }
@ -1154,10 +1155,10 @@ inline namespace core
inline basic_string<_CharTy> basic_string<_CharTy>::parse(unsigned long long val) { return ::kiwano::to_basic_string<char_type>(val); }
template <typename _CharTy>
inline basic_string<_CharTy> basic_string<_CharTy>::parse(float val) { return ::kiwano::to_basic_string<char_type>(val); }
inline basic_string<_CharTy> basic_string<_CharTy>::parse(Float32 val) { return ::kiwano::to_basic_string<char_type>(val); }
template <typename _CharTy>
inline basic_string<_CharTy> basic_string<_CharTy>::parse(double val) { return ::kiwano::to_basic_string<char_type>(val); }
inline basic_string<_CharTy> basic_string<_CharTy>::parse(Float64 val) { return ::kiwano::to_basic_string<char_type>(val); }
template <typename _CharTy>
inline basic_string<_CharTy> basic_string<_CharTy>::parse(long double val) { return ::kiwano::to_basic_string<char_type>(val); }
@ -1312,13 +1313,13 @@ inline namespace core
}
template <typename _CharTy>
inline basic_string<_CharTy> to_basic_string(int val)
inline basic_string<_CharTy> to_basic_string(Int32 val)
{
return (__to_string_detail::IntegralToString<_CharTy>::convert(val));
}
template <typename _CharTy>
inline basic_string<_CharTy> to_basic_string(unsigned int val)
inline basic_string<_CharTy> to_basic_string(UInt32 val)
{
return (__to_string_detail::IntegralToString<_CharTy>::convert(val));
}
@ -1348,13 +1349,13 @@ inline namespace core
}
template <typename _CharTy>
inline basic_string<_CharTy> to_basic_string(float val)
inline basic_string<_CharTy> to_basic_string(Float32 val)
{
return (__to_string_detail::FloatingToString<_CharTy>::convert(val));
}
template <typename _CharTy>
inline basic_string<_CharTy> to_basic_string(double val)
inline basic_string<_CharTy> to_basic_string(Float64 val)
{
return (__to_string_detail::FloatingToString<_CharTy>::convert(val));
}
@ -1380,9 +1381,9 @@ inline namespace core
}
template <typename ..._Args>
inline basic_string<wchar_t> format_string(const wchar_t* const fmt, _Args&& ... args)
inline basic_string<WChar> format_string(const WChar* const fmt, _Args&& ... args)
{
using string_type = basic_string<wchar_t>;
using string_type = basic_string<WChar>;
const auto len = static_cast<typename string_type::size_type>(::_scwprintf(fmt, ::std::forward<_Args>(args)...));
if (len)
{
@ -1437,37 +1438,37 @@ inline namespace core
};
template <>
struct IntegralToString<wchar_t>
struct IntegralToString<WChar>
{
template <typename _Ty>
static basic_string<wchar_t> convert(const _Ty val)
static basic_string<WChar> convert(const _Ty val)
{
static_assert(::std::is_integral<_Ty>::value, "_Ty must be integral");
using _Elem = typename basic_string<wchar_t>::traits_type::char_type;
using _Elem = typename basic_string<WChar>::traits_type::char_type;
_Elem buffer[21];
_Elem* const buffer_end = ::std::end(buffer);
_Elem* buffer_begin = __IntegerToStringBufferEnd(val, buffer_end);
return basic_string<wchar_t>(buffer_begin, buffer_end);
return basic_string<WChar>(buffer_begin, buffer_end);
}
};
template<>
struct FloatingToString<wchar_t>
struct FloatingToString<WChar>
{
static inline basic_string<wchar_t> convert(const float val)
static inline basic_string<WChar> convert(const Float32 val)
{
return format_string(L"%g", val);
}
static inline basic_string<wchar_t> convert(const double val)
static inline basic_string<WChar> convert(const Float64 val)
{
return format_string(L"%g", val);
}
static inline basic_string<wchar_t> convert(const long double val)
static inline basic_string<WChar> convert(const long double val)
{
return format_string(L"%Lg", val);
}
@ -1476,12 +1477,12 @@ inline namespace core
template<>
struct FloatingToString<char>
{
static inline basic_string<char> convert(const float val)
static inline basic_string<char> convert(const Float32 val)
{
return format_string("%g", val);
}
static inline basic_string<char> convert(const double val)
static inline basic_string<char> convert(const Float64 val)
{
return format_string("%g", val);
}
@ -1498,7 +1499,7 @@ inline namespace core
namespace kiwano
{
template <typename _Codecvt, typename _Elem = wchar_t>
template <typename _Codecvt, typename _Elem = WChar>
class string_convert
{
enum { BUFFER_INCREASE = 8, BUFFER_MAX = 16 };
@ -1526,7 +1527,7 @@ public:
virtual ~string_convert() { }
size_t converted() const noexcept { return conv_num_; }
UInt32 converted() const noexcept { return conv_num_; }
state_type state() const { return state_; }
@ -1553,8 +1554,8 @@ public:
state_ = state_type{};
wbuf.append((::std::size_t) BUFFER_INCREASE, (_Elem) '\0');
for (conv_num_ = 0; first != last; conv_num_ = static_cast<size_t>(first - first_save))
wbuf.append((UInt32) BUFFER_INCREASE, (_Elem) '\0');
for (conv_num_ = 0; first != last; conv_num_ = static_cast<UInt32>(first - first_save))
{
_Elem* dest = &*wbuf.begin();
_Elem* dnext;
@ -1566,11 +1567,11 @@ public:
{
if (dest < dnext)
{
wstr.append(dest, static_cast<size_t>(dnext - dest));
wstr.append(dest, static_cast<UInt32>(dnext - dest));
}
else if (wbuf.size() < BUFFER_MAX)
{
wbuf.append(static_cast<size_t>(BUFFER_INCREASE), '\0');
wbuf.append(static_cast<UInt32>(BUFFER_INCREASE), '\0');
}
else
{
@ -1583,7 +1584,7 @@ public:
{
// no conversion, just copy code values
for (; first != last; ++first) {
wstr.push_back((_Elem)(unsigned char)* first);
wstr.push_back((_Elem)(UChar)* first);
}
break;
}
@ -1621,8 +1622,8 @@ public:
state_ = state_type{};
bbuf.append((::std::size_t) BUFFER_INCREASE, '\0');
for (conv_num_ = 0; first != last; conv_num_ = static_cast<size_t>(first - first_save))
bbuf.append((UInt32) BUFFER_INCREASE, '\0');
for (conv_num_ = 0; first != last; conv_num_ = static_cast<UInt32>(first - first_save))
{
char* dest = &*bbuf.begin();
char* dnext;
@ -1634,11 +1635,11 @@ public:
{
if (dest < dnext)
{
bstr.append(dest, (::std::size_t)(dnext - dest));
bstr.append(dest, (UInt32)(dnext - dest));
}
else if (bbuf.size() < BUFFER_MAX)
{
bbuf.append((::std::size_t) BUFFER_INCREASE, '\0');
bbuf.append((UInt32) BUFFER_INCREASE, '\0');
}
else
{
@ -1670,11 +1671,11 @@ private:
const codecvt_type* cvt_;
::std::locale loc_;
state_type state_;
size_t conv_num_;
UInt32 conv_num_;
};
class chs_codecvt
: public ::std::codecvt_byname<wchar_t, char, ::std::mbstate_t>
: public ::std::codecvt_byname<WChar, char, ::std::mbstate_t>
{
public:
chs_codecvt() : codecvt_byname("chs") {}
@ -1709,7 +1710,7 @@ namespace std
template<>
struct hash<::kiwano::core::string>
{
inline size_t operator()(const ::kiwano::core::string& key) const
inline std::size_t operator()(const ::kiwano::core::string& key) const
{
return key.hash();
}
@ -1718,7 +1719,7 @@ namespace std
template<>
struct hash<::kiwano::core::wstring>
{
inline size_t operator()(const ::kiwano::core::wstring& key) const
inline std::size_t operator()(const ::kiwano::core::wstring& key) const
{
return key.hash();
}

45
src/kiwano/core/types.h Normal file
View File

@ -0,0 +1,45 @@
// Copyright (c) 2016-2018 Kiwano - Nomango
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#pragma once
#include <cstdint>
#define KGE_DEFINE_NUMERIC_TYPE(TYPE, OLD_TYPE) using TYPE = OLD_TYPE;
namespace kiwano
{
KGE_DEFINE_NUMERIC_TYPE(Char, signed char);
KGE_DEFINE_NUMERIC_TYPE(UChar, unsigned char);
KGE_DEFINE_NUMERIC_TYPE(WChar, wchar_t);
KGE_DEFINE_NUMERIC_TYPE(Int8, std::int8_t);
KGE_DEFINE_NUMERIC_TYPE(Int16, std::int16_t);
KGE_DEFINE_NUMERIC_TYPE(Int32, std::int32_t);
KGE_DEFINE_NUMERIC_TYPE(Int64, std::int64_t);
KGE_DEFINE_NUMERIC_TYPE(UInt8, std::uint8_t);
KGE_DEFINE_NUMERIC_TYPE(UInt16, std::uint16_t);
KGE_DEFINE_NUMERIC_TYPE(UInt32, std::uint32_t);
KGE_DEFINE_NUMERIC_TYPE(UInt64, std::uint64_t);
KGE_DEFINE_NUMERIC_TYPE(Float32, float);
KGE_DEFINE_NUMERIC_TYPE(Float64, double);
}

View File

@ -19,6 +19,7 @@
// THE SOFTWARE.
#pragma once
#include "types.h"
#include <memory>
#include <type_traits>
#include <exception>
@ -51,7 +52,7 @@ class vector
{
public:
using value_type = _Ty;
using size_type = std::size_t;
using size_type = UInt32;
using iterator = value_type * ;
using const_iterator = const value_type*;
using reference = value_type & ;
@ -217,12 +218,12 @@ namespace __vector_details
struct vector_memory_manager<_Ty, _Alloc, false>
{
using value_type = _Ty;
using size_type = size_t;
using size_type = UInt32;
using allocator_type = typename _Alloc;
static void copy_data(value_type* dest, const value_type* src, size_type count) { if (src == dest) return; ::memcpy(dest, src, (size_t)count * sizeof(value_type)); }
static void copy_data(value_type* dest, size_type count, const value_type& val) { ::memset(dest, (int)val, (size_t)count * sizeof(value_type)); }
static void move_data(value_type* dest, const value_type* src, size_type count) { if (src == dest) return; ::memmove(dest, src, (size_t)count * sizeof(value_type)); }
static void copy_data(value_type* dest, const value_type* src, size_type count) { if (src == dest) return; ::memcpy(dest, src, (UInt32)count * sizeof(value_type)); }
static void copy_data(value_type* dest, size_type count, const value_type& val) { ::memset(dest, (Int32)val, (UInt32)count * sizeof(value_type)); }
static void move_data(value_type* dest, const value_type* src, size_type count) { if (src == dest) return; ::memmove(dest, src, (UInt32)count * sizeof(value_type)); }
static value_type* allocate(size_type count) { return get_allocator().allocate(count); }
static void deallocate(value_type*& ptr, size_type count) { if (ptr) { get_allocator().deallocate(ptr, count); ptr = nullptr; } }
@ -246,7 +247,7 @@ namespace __vector_details
struct vector_memory_manager<_Ty, _Alloc, true>
{
using value_type = _Ty;
using size_type = size_t;
using size_type = UInt32;
using allocator_type = typename _Alloc;
static void copy_data(value_type* dest, const value_type* src, size_type count) { if (src == dest) return; while (count--) (*dest++) = (*src++); }

View File

@ -67,7 +67,7 @@ namespace kiwano
explicit Matrix3x2T(const value_type* p)
{
for (int i = 0; i < 6; i++)
for (Int32 i = 0; i < 6; i++)
m[i] = p[i];
}
@ -81,23 +81,23 @@ namespace kiwano
template <typename _MTy>
Matrix3x2T(_MTy const& other)
{
for (int i = 0; i < 6; i++)
for (Int32 i = 0; i < 6; i++)
m[i] = other[i];
}
inline value_type operator [](unsigned int index) const
inline value_type operator [](UInt32 index) const
{
return m[index];
}
inline value_type& operator [](unsigned int index)
inline value_type& operator [](UInt32 index)
{
return m[index];
}
inline Matrix3x2T& operator= (Matrix3x2T const& other)
{
for (int i = 0; i < 6; i++)
for (Int32 i = 0; i < 6; i++)
m[i] = other[i];
return (*this);
}
@ -285,7 +285,7 @@ namespace kiwano
, rhs(rhs)
{}
inline _Ty operator [](unsigned int index) const
inline _Ty operator [](UInt32 index) const
{
switch (index)
{
@ -327,5 +327,5 @@ namespace kiwano
namespace kiwano
{
using Matrix3x2 = kiwano::math::Matrix3x2T<float>;
using Matrix3x2 = kiwano::math::Matrix3x2T<Float32>;
}

View File

@ -120,5 +120,5 @@ namespace kiwano
namespace kiwano
{
using Rect = kiwano::math::RectT<float>;
using Rect = kiwano::math::RectT<Float32>;
}

View File

@ -41,7 +41,7 @@ namespace kiwano
inline value_type Length() const
{
return static_cast<value_type>(math::Sqrt(static_cast<float>(x * x + y * y)));
return static_cast<value_type>(math::Sqrt(static_cast<Float32>(x * x + y * y)));
}
inline bool IsOrigin() const
@ -123,5 +123,5 @@ namespace kiwano
namespace kiwano
{
using Vec2 = kiwano::math::Vec2T<float>;
using Vec2 = kiwano::math::Vec2T<Float32>;
}

View File

@ -25,7 +25,7 @@ namespace kiwano
{
namespace math
{
inline float Linear(float step)
inline Float32 Linear(Float32 step)
{
return step;
}
@ -33,17 +33,17 @@ namespace kiwano
// Ease
inline float EaseIn(float step, float rate)
inline Float32 EaseIn(Float32 step, Float32 rate)
{
return math::Pow(step, rate);
}
inline float EaseOut(float step, float rate)
inline Float32 EaseOut(Float32 step, Float32 rate)
{
return math::Pow(step, 1.f / rate);
}
inline float EaseInOut(float step, float rate)
inline Float32 EaseInOut(Float32 step, Float32 rate)
{
if (step < .5f)
return .5f * math::Pow(2 * step, rate);
@ -53,17 +53,17 @@ namespace kiwano
// Exponential Ease
inline float EaseExponentialIn(float step)
inline Float32 EaseExponentialIn(Float32 step)
{
return math::Pow(2.f, 10 * (step - 1));
}
inline float EaseExponentialOut(float step)
inline Float32 EaseExponentialOut(Float32 step)
{
return 1.f - math::Pow(2.f, -10 * step);
}
inline float EaseExponentialInOut(float step)
inline Float32 EaseExponentialInOut(Float32 step)
{
if (step < .5f)
return .5f * math::Pow(2.f, 10 * (2 * step - 1));
@ -73,7 +73,7 @@ namespace kiwano
// Bounce Ease
inline float EaseBounceOut(float step)
inline Float32 EaseBounceOut(Float32 step)
{
if (step < 1 / 2.75f)
{
@ -94,12 +94,12 @@ namespace kiwano
return 7.5625f * step * step + 0.984375f;
}
inline float EaseBounceIn(float step)
inline Float32 EaseBounceIn(Float32 step)
{
return 1 - EaseBounceOut(1 - step);
}
inline float EaseBounceInOut(float step)
inline Float32 EaseBounceInOut(Float32 step)
{
if (step < 0.5f)
{
@ -114,7 +114,7 @@ namespace kiwano
// Elastic Ease
inline float EaseElasticIn(float step, float period)
inline Float32 EaseElasticIn(Float32 step, Float32 period)
{
if (step == 0 || step == 1)
return step;
@ -123,7 +123,7 @@ namespace kiwano
return -math::Pow(2, 10 * step) * math::Sin((step - period / 4) * 360.f / period);
}
inline float EaseElasticOut(float step, float period)
inline Float32 EaseElasticOut(Float32 step, Float32 period)
{
if (step == 0 || step == 1)
return step;
@ -131,7 +131,7 @@ namespace kiwano
return math::Pow(2, -10 * step) * math::Sin((step - period / 4) * 360.f / period) + 1;
}
inline float EaseElasticInOut(float step, float period)
inline Float32 EaseElasticInOut(Float32 step, Float32 period)
{
if (step == 0 || step == 1)
return step;
@ -147,22 +147,22 @@ namespace kiwano
// Back Ease
inline float EaseBackIn(float step)
inline Float32 EaseBackIn(Float32 step)
{
const float overshoot = 1.70158f;
const Float32 overshoot = 1.70158f;
return step * step * ((overshoot + 1) * step - overshoot);
}
inline float EaseBackOut(float step)
inline Float32 EaseBackOut(Float32 step)
{
const float overshoot = 1.70158f;
const Float32 overshoot = 1.70158f;
step = step - 1;
return step * step * ((overshoot + 1) * step + overshoot) + 1;
}
inline float EaseBackInOut(float step)
inline Float32 EaseBackInOut(Float32 step)
{
const float overshoot = 1.70158f * 1.525f;
const Float32 overshoot = 1.70158f * 1.525f;
step = step * 2;
if (step < 1)
@ -177,17 +177,17 @@ namespace kiwano
// Sine Ease
inline float EaseSineIn(float step)
inline Float32 EaseSineIn(Float32 step)
{
return 1.f - math::Cos(step * 90);
}
inline float EaseSineOut(float step)
inline Float32 EaseSineOut(Float32 step)
{
return math::Sin(step * 90);
}
inline float EaseSineInOut(float step)
inline Float32 EaseSineInOut(Float32 step)
{
return -0.5f * (math::Cos(step * 180) - 1);
}
@ -195,17 +195,17 @@ namespace kiwano
// Quad Ease
inline float EaseQuadIn(float step)
inline Float32 EaseQuadIn(Float32 step)
{
return step * step;
}
inline float EaseQuadOut(float step)
inline Float32 EaseQuadOut(Float32 step)
{
return -1 * step * (step - 2);
}
inline float EaseQuadInOut(float step)
inline Float32 EaseQuadInOut(Float32 step)
{
step = step * 2;
if (step < 1)
@ -217,18 +217,18 @@ namespace kiwano
// Cubic Ease
inline float EaseCubicIn(float step)
inline Float32 EaseCubicIn(Float32 step)
{
return step * step * step;
}
inline float EaseCubicOut(float step)
inline Float32 EaseCubicOut(Float32 step)
{
step -= 1;
return (step * step * step + 1);
}
inline float EaseCubicInOut(float step)
inline Float32 EaseCubicInOut(Float32 step)
{
step = step * 2;
if (step < 1)
@ -240,18 +240,18 @@ namespace kiwano
// Quart Ease
inline float EaseQuartIn(float step)
inline Float32 EaseQuartIn(Float32 step)
{
return step * step * step * step;
}
inline float EaseQuartOut(float step)
inline Float32 EaseQuartOut(Float32 step)
{
step -= 1;
return -(step * step * step * step - 1);
}
inline float EaseQuartInOut(float step)
inline Float32 EaseQuartInOut(Float32 step)
{
step = step * 2;
if (step < 1)
@ -263,18 +263,18 @@ namespace kiwano
// Quint Ease
inline float EaseQuintIn(float step)
inline Float32 EaseQuintIn(Float32 step)
{
return step * step * step * step * step;
}
inline float EaseQuintOut(float step)
inline Float32 EaseQuintOut(Float32 step)
{
step -= 1;
return (step * step * step * step * step + 1);
}
inline float EaseQuintInOut(float step)
inline Float32 EaseQuintInOut(Float32 step)
{
step = step * 2;
if (step < 1)

View File

@ -29,14 +29,14 @@ namespace kiwano
// 随机数
//
// 获取指定范围内的一个随机数, 如:
// int n = math::Rand(1, 5); // 获取 1~5 内的随机整数, 包含 1 和 5
// Int32 n = math::Rand(1, 5); // 获取 1~5 内的随机整数, 包含 1 和 5
// 产生的随机数类型取决于参数的类型, 如获取随机浮点数:
// double d = math::Rand(1.2, 1.5);
// Float64 d = math::Rand(1.2, 1.5);
//
int Rand(int min, int max);
Int32 Rand(Int32 min, Int32 max);
unsigned int Rand(unsigned int min, unsigned int max);
UInt32 Rand(UInt32 min, UInt32 max);
long Rand(long min, long max);
@ -44,11 +44,11 @@ namespace kiwano
char Rand(char min, char max);
unsigned char Rand(unsigned char min, unsigned char max);
UChar Rand(UChar min, UChar max);
float Rand(float min, float max);
Float32 Rand(Float32 min, Float32 max);
double Rand(double min, double max);
Float64 Rand(Float64 min, Float64 max);
//
@ -79,12 +79,12 @@ namespace kiwano
}
}
inline int Rand(int min, int max)
inline Int32 Rand(Int32 min, Int32 max)
{
return __rand_detail::RandomInt(min, max);
}
inline unsigned int Rand(unsigned int min, unsigned int max)
inline UInt32 Rand(UInt32 min, UInt32 max)
{
return __rand_detail::RandomInt(min, max);
}
@ -102,23 +102,23 @@ namespace kiwano
inline char Rand(char min, char max)
{
return static_cast<char>(
__rand_detail::RandomInt(static_cast<int>(min), static_cast<int>(max))
__rand_detail::RandomInt(static_cast<Int32>(min), static_cast<Int32>(max))
);
}
inline unsigned char Rand(unsigned char min, unsigned char max)
inline UChar Rand(UChar min, UChar max)
{
return static_cast<unsigned char>(
__rand_detail::RandomInt(static_cast<unsigned int>(min), static_cast<unsigned int>(max))
return static_cast<UChar>(
__rand_detail::RandomInt(static_cast<UInt32>(min), static_cast<UInt32>(max))
);
}
inline float Rand(float min, float max)
inline Float32 Rand(Float32 min, Float32 max)
{
return __rand_detail::RandomReal(min, max);
}
inline double Rand(double min, double max)
inline Float64 Rand(Float64 min, Float64 max)
{
return __rand_detail::RandomReal(min, max);
}

View File

@ -27,56 +27,56 @@ namespace kiwano
{
namespace math
{
inline int Abs(int val) { return ::abs(val); }
inline Int32 Abs(Int32 val) { return ::abs(val); }
inline float Abs(float val) { return ::fabsf(val); }
inline Float32 Abs(Float32 val) { return ::fabsf(val); }
inline double Abs(double val) { return ::fabs(val); }
inline Float64 Abs(Float64 val) { return ::fabs(val); }
inline float Sqrt(float val) { return ::sqrtf(val); }
inline Float32 Sqrt(Float32 val) { return ::sqrtf(val); }
inline double Sqrt(double val) { return ::sqrt(val); }
inline Float64 Sqrt(Float64 val) { return ::sqrt(val); }
inline float Pow(float base, float exponent) { return ::powf(base, exponent); }
inline Float32 Pow(Float32 base, Float32 exponent) { return ::powf(base, exponent); }
inline double Pow(double base, double exponent) { return ::pow(base, exponent); }
inline Float64 Pow(Float64 base, Float64 exponent) { return ::pow(base, exponent); }
inline int Sign(int val) { return val < 0 ? -1 : 1; }
inline Int32 Sign(Int32 val) { return val < 0 ? -1 : 1; }
inline float Sign(float val) { return val < 0 ? -1.f : 1.f; }
inline Float32 Sign(Float32 val) { return val < 0 ? -1.f : 1.f; }
inline double Sign(double val) { return val < 0 ? -1.0 : 1.0; }
inline Float64 Sign(Float64 val) { return val < 0 ? -1.0 : 1.0; }
inline float Sin(float val) { return ::sinf(val * constants::PI_F / 180.f); }
inline Float32 Sin(Float32 val) { return ::sinf(val * constants::PI_F / 180.f); }
inline double Sin(double val) { return ::sin(val * constants::PI_D / 180.0); }
inline Float64 Sin(Float64 val) { return ::sin(val * constants::PI_D / 180.0); }
inline float Cos(float val) { return ::cosf(val * constants::PI_F / 180.f); }
inline Float32 Cos(Float32 val) { return ::cosf(val * constants::PI_F / 180.f); }
inline double Cos(double val) { return ::cos(val * constants::PI_D / 180.0); }
inline Float64 Cos(Float64 val) { return ::cos(val * constants::PI_D / 180.0); }
inline float Tan(float val) { return ::tanf(val * constants::PI_F / 180.f); }
inline Float32 Tan(Float32 val) { return ::tanf(val * constants::PI_F / 180.f); }
inline double Tan(double val) { return ::tan(val * constants::PI_D / 180.0); }
inline Float64 Tan(Float64 val) { return ::tan(val * constants::PI_D / 180.0); }
inline float Asin(float val) { return ::asinf(val) * 180.f / constants::PI_F; }
inline Float32 Asin(Float32 val) { return ::asinf(val) * 180.f / constants::PI_F; }
inline double Asin(double val) { return ::asin(val) * 180.f / constants::PI_F; }
inline Float64 Asin(Float64 val) { return ::asin(val) * 180.f / constants::PI_F; }
inline float Acos(float val) { return ::acosf(val) * 180.f / constants::PI_F; }
inline Float32 Acos(Float32 val) { return ::acosf(val) * 180.f / constants::PI_F; }
inline double Acos(double val) { return ::acos(val) * 180.f / constants::PI_F; }
inline Float64 Acos(Float64 val) { return ::acos(val) * 180.f / constants::PI_F; }
inline float Atan(float val) { return ::atanf(val) * 180.f / constants::PI_F; }
inline Float32 Atan(Float32 val) { return ::atanf(val) * 180.f / constants::PI_F; }
inline double Atan(double val) { return ::atan(val) * 180.f / constants::PI_F; }
inline Float64 Atan(Float64 val) { return ::atan(val) * 180.f / constants::PI_F; }
inline float Ceil(float val) { return ::ceil(val); }
inline Float32 Ceil(Float32 val) { return ::ceil(val); }
inline double Ceil(double val) { return ::ceil(val); }
inline Float64 Ceil(Float64 val) { return ::ceil(val); }
inline float Floor(float val) { return ::floor(val); }
inline Float32 Floor(Float32 val) { return ::floor(val); }
inline double Floor(double val) { return ::floor(val); }
inline Float64 Floor(Float64 val) { return ::floor(val); }
}
}

View File

@ -43,7 +43,7 @@ namespace kiwano
Queue<FunctionToPerform> functions_to_perform_;
}
Options::Options(String const& title, int width, int height, LPCWSTR icon, Color clear_color, bool vsync, bool fullscreen, bool debug)
Options::Options(String const& title, Int32 width, Int32 height, LPCWSTR icon, Color clear_color, bool vsync, bool fullscreen, bool debug)
: title(title)
, width(width)
, height(height)
@ -205,7 +205,7 @@ namespace kiwano
}
}
void Application::SetTimeScale(float scale_factor)
void Application::SetTimeScale(Float32 scale_factor)
{
time_scale_ = scale_factor;
}
@ -295,7 +295,7 @@ namespace kiwano
functions_to_perform_.push(Function);
}
LRESULT CALLBACK Application::WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
LRESULT CALLBACK Application::WndProc(HWND hwnd, UInt32 msg, WPARAM wparam, LPARAM lparam)
{
Application * app = reinterpret_cast<Application*>(static_cast<LONG_PTR>(::GetWindowLongPtrW(hwnd, GWLP_USERDATA)));
@ -327,8 +327,8 @@ namespace kiwano
{
bool down = msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN;
Event evt(down ? Event::KeyDown : Event::KeyUp);
evt.key.code = static_cast<int>(wparam);
evt.key.count = static_cast<int>(lparam & 0xFF);
evt.key.code = static_cast<Int32>(wparam);
evt.key.count = static_cast<Int32>(lparam & 0xFF);
app->DispatchEvent(evt);
}
@ -338,7 +338,7 @@ namespace kiwano
{
Event evt(Event::Char);
evt.key.c = static_cast<char>(wparam);
evt.key.count = static_cast<int>(lparam & 0xFF);
evt.key.count = static_cast<Int32>(lparam & 0xFF);
app->DispatchEvent(evt);
}
@ -358,15 +358,15 @@ namespace kiwano
{
Event evt;
evt.mouse.x = static_cast<float>(GET_X_LPARAM(lparam));
evt.mouse.y = static_cast<float>(GET_Y_LPARAM(lparam));
evt.mouse.x = static_cast<Float32>(GET_X_LPARAM(lparam));
evt.mouse.y = static_cast<Float32>(GET_Y_LPARAM(lparam));
evt.mouse.left_btn_down = !!(wparam & MK_LBUTTON);
evt.mouse.left_btn_down = !!(wparam & MK_RBUTTON);
if (msg == WM_MOUSEMOVE) { evt.type = Event::MouseMove; }
else if (msg == WM_LBUTTONDOWN || msg == WM_RBUTTONDOWN || msg == WM_MBUTTONDOWN) { evt.type = Event::MouseBtnDown; }
else if (msg == WM_LBUTTONUP || msg == WM_RBUTTONUP || msg == WM_MBUTTONUP) { evt.type = Event::MouseBtnUp; }
else if (msg == WM_MOUSEWHEEL) { evt.type = Event::MouseWheel; evt.mouse.wheel = GET_WHEEL_DELTA_WPARAM(wparam) / (float)WHEEL_DELTA; }
else if (msg == WM_MOUSEWHEEL) { evt.type = Event::MouseWheel; evt.mouse.wheel = GET_WHEEL_DELTA_WPARAM(wparam) / (Float32)WHEEL_DELTA; }
if (msg == WM_LBUTTONDOWN || msg == WM_LBUTTONUP) { evt.mouse.button = MouseButton::Left; }
else if (msg == WM_RBUTTONDOWN || msg == WM_RBUTTONUP) { evt.mouse.button = MouseButton::Right; }
@ -398,8 +398,8 @@ namespace kiwano
case WM_MOVE:
{
int x = (int)(short)LOWORD(lparam);
int y = (int)(short)HIWORD(lparam);
Int32 x = (Int32)(short)LOWORD(lparam);
Int32 y = (Int32)(short)HIWORD(lparam);
Event evt(Event::WindowMoved);
evt.win.x = x;
@ -425,7 +425,7 @@ namespace kiwano
KGE_LOG(L"Window title changed");
Event evt(Event::WindowTitleChanged);
evt.win.title = reinterpret_cast<const wchar_t*>(lparam);
evt.win.title = reinterpret_cast<const WChar*>(lparam);
app->DispatchEvent(evt);
}
break;

View File

@ -30,8 +30,8 @@ namespace kiwano
struct Options
{
String title; // 标题
int width; // 宽度
int height; // 高度
Int32 width; // 宽度
Int32 height; // 高度
LPCWSTR icon; // 图标
Color clear_color; // 清屏颜色
bool vsync; // 垂直同步
@ -40,8 +40,8 @@ namespace kiwano
Options(
String const& title = L"Kiwano Game",
int width = 640,
int height = 480,
Int32 width = 640,
Int32 height = 480,
LPCWSTR icon = nullptr,
Color clear_color = Color::Black,
bool vsync = true,
@ -95,7 +95,7 @@ namespace kiwano
// 设置时间缩放因子
void SetTimeScale(
float scale_factor
Float32 scale_factor
);
// 分发事件
@ -112,12 +112,12 @@ namespace kiwano
void Update();
static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
static LRESULT CALLBACK WndProc(HWND, UInt32, WPARAM, LPARAM);
protected:
bool end_;
bool inited_;
float time_scale_;
Float32 time_scale_;
Vector<Component*> components_;
};

View File

@ -24,13 +24,13 @@ namespace kiwano
{
namespace
{
const unsigned int RED_SHIFT = 16;
const unsigned int GREEN_SHIFT = 8;
const unsigned int BLUE_SHIFT = 0;
const UInt32 RED_SHIFT = 16;
const UInt32 GREEN_SHIFT = 8;
const UInt32 BLUE_SHIFT = 0;
const unsigned int RED_MASK = 0xff << RED_SHIFT;
const unsigned int GREEN_MASK = 0xff << GREEN_SHIFT;
const unsigned int BLUE_MASK = 0xff << BLUE_SHIFT;
const UInt32 RED_MASK = 0xff << RED_SHIFT;
const UInt32 GREEN_MASK = 0xff << GREEN_SHIFT;
const UInt32 BLUE_MASK = 0xff << BLUE_SHIFT;
}
Color::Color()
@ -41,7 +41,7 @@ namespace kiwano
{
}
Color::Color(float r, float g, float b)
Color::Color(Float32 r, Float32 g, Float32 b)
: r(r)
, g(g)
, b(b)
@ -49,7 +49,7 @@ namespace kiwano
{
}
Color::Color(float r, float g, float b, float alpha)
Color::Color(Float32 r, Float32 g, Float32 b, Float32 alpha)
: r(r)
, g(g)
, b(b)
@ -57,7 +57,7 @@ namespace kiwano
{
}
Color::Color(unsigned int rgb)
Color::Color(UInt32 rgb)
: r(((rgb & RED_MASK) >> RED_SHIFT) / 255.f)
, g(((rgb & GREEN_MASK) >> GREEN_SHIFT) / 255.f)
, b(((rgb & BLUE_MASK) >> BLUE_SHIFT) / 255.f)
@ -65,7 +65,7 @@ namespace kiwano
{
}
Color::Color(unsigned int rgb, float alpha)
Color::Color(UInt32 rgb, Float32 alpha)
: r(((rgb & RED_MASK) >> RED_SHIFT) / 255.f)
, g(((rgb & GREEN_MASK) >> GREEN_SHIFT) / 255.f)
, b(((rgb & BLUE_MASK) >> BLUE_SHIFT) / 255.f)

View File

@ -20,6 +20,7 @@
#pragma once
#include "../macros.h"
#include "../core/core.h"
namespace kiwano
{
@ -28,7 +29,7 @@ namespace kiwano
// 使用枚举表示颜色: Color blue = Color::Blue;
// 使用 RGB 表示一个颜色: Color red(1.0f, 0.0f, 0.0f);
// 使用 RGBA 表示一个带透明度的颜色: Color not_black(1.0f, 1.0f, 1.0f, 0.5f);
// 使用一个 unsigned int 类型的值表示 RGB: Color black(0x000000);
// 使用一个 UInt32 类型的值表示 RGB: Color black(0x000000);
//
class KGE_API Color
{
@ -36,29 +37,29 @@ namespace kiwano
Color();
Color(
float r,
float g,
float b
Float32 r,
Float32 g,
Float32 b
);
Color(
float r,
float g,
float b,
float alpha
Float32 r,
Float32 g,
Float32 b,
Float32 alpha
);
Color(
unsigned int rgb
UInt32 rgb
);
Color(
unsigned int rgb,
float alpha
UInt32 rgb,
Float32 alpha
);
public:
enum Value : unsigned int
enum Value : UInt32
{
Black = 0x000000,
Blue = 0x0000FF,
@ -102,9 +103,9 @@ namespace kiwano
};
public:
float r;
float g;
float b;
float a;
Float32 r;
Float32 g;
Float32 b;
Float32 a;
};
}

View File

@ -22,7 +22,7 @@
namespace kiwano
{
Font::Font(const String& family, float size, unsigned int weight, bool italic, FontCollection collection)
Font::Font(const String& family, Float32 size, UInt32 weight, bool italic, FontCollection collection)
: family(family)
, size(size)
, weight(weight)

View File

@ -24,7 +24,7 @@
namespace kiwano
{
// 字体粗细值
enum FontWeight : unsigned int
enum FontWeight : UInt32
{
Thin = 100,
ExtraLight = 200,
@ -42,16 +42,16 @@ namespace kiwano
{
public:
String family; // 字体族
float size; // ×ÖºÅ
unsigned int weight; // ´Öϸֵ
Float32 size; // ×ÖºÅ
UInt32 weight; // ´Öϸֵ
bool italic; // 是否斜体
FontCollection collection; // 字体集
public:
Font(
const String& family = L"",
float size = 18,
unsigned int weight = FontWeight::Normal,
Float32 size = 18,
UInt32 weight = FontWeight::Normal,
bool italic = false,
FontCollection collection = FontCollection()
);

View File

@ -49,9 +49,9 @@ namespace kiwano
return Rect{ rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top };
}
float Geometry::GetLength()
Float32 Geometry::GetLength()
{
float length = 0.f;
Float32 length = 0.f;
if (geo_)
{
// no matter it failed or not
@ -60,7 +60,7 @@ namespace kiwano
return length;
}
bool Geometry::ComputePointAtLength(float length, Point& point, Vec2& tangent)
bool Geometry::ComputePointAtLength(Float32 length, Point& point, Vec2& tangent)
{
if (geo_)
{
@ -108,7 +108,7 @@ namespace kiwano
sink.Init();
sink.OpenSink();
for (size_t i = 0; i < geos.size() - 1; i++)
for (UInt32 i = 0; i < geos.size() - 1; i++)
{
CombineMode mode = (modes.size() == 1) ? modes[0] : modes[i];
const Matrix3x2& matrix = (matrixs.size() == 1) ? matrixs[0] : matrixs[i];
@ -129,12 +129,12 @@ namespace kiwano
return Geometry();
}
float Geometry::ComputeArea()
Float32 Geometry::ComputeArea()
{
if (!geo_)
return 0.f;
float area = 0.f;
Float32 area = 0.f;
// no matter it failed or not
geo_->ComputeArea(D2D1::Matrix3x2F::Identity(), &area);
return area;
@ -176,7 +176,7 @@ namespace kiwano
return output;
}
Geometry Geometry::CreateCircle(Point const& center, float radius)
Geometry Geometry::CreateCircle(Point const& center, Float32 radius)
{
Geometry output;
Renderer::GetInstance()->CreateEllipseGeometry(output, center, Vec2{ radius, radius });
@ -236,7 +236,7 @@ namespace kiwano
sink_->AddLines(
reinterpret_cast<const D2D_POINT_2F*>(&points[0]),
static_cast<UINT32>(points.size())
static_cast<UInt32>(points.size())
);
return (*this);
}
@ -255,7 +255,7 @@ namespace kiwano
return (*this);
}
GeometrySink& GeometrySink::AddArc(Point const& point, Size const& radius, float rotation, bool clockwise, bool is_small)
GeometrySink& GeometrySink::AddArc(Point const& point, Size const& radius, Float32 rotation, bool clockwise, bool is_small)
{
if (!sink_) BeginPath();

View File

@ -53,14 +53,14 @@ namespace kiwano
);
// 获取图形展开成一条直线的长度
float GetLength();
Float32 GetLength();
// 计算面积
float ComputeArea();
Float32 ComputeArea();
// 计算图形路径上点的位置和切线向量
bool ComputePointAtLength(
float length,
Float32 length,
Point& point,
Vec2& tangent
);
@ -100,7 +100,7 @@ namespace kiwano
// 创建圆形
static Geometry CreateCircle(
Point const& center,
float radius
Float32 radius
);
// 创建椭圆形
@ -159,7 +159,7 @@ namespace kiwano
GeometrySink& AddArc(
Point const& point, /* 终点 */
Size const& radius, /* 椭圆半径 */
float rotation, /* ÍÖÔ²Ðýת½Ç¶È */
Float32 rotation, /* ÍÖÔ²Ðýת½Ç¶È */
bool clockwise = true, /* 顺时针 or 逆时针 */
bool is_small = true /* 是否取小于 180° 的弧 */
);

View File

@ -82,8 +82,8 @@ namespace kiwano
HRESULT GifImage::GetGlobalMetadata()
{
unsigned int width = 0;
unsigned int height = 0;
UInt32 width = 0;
UInt32 height = 0;
PROPVARIANT prop_val;
::PropVariantInit(&prop_val);
@ -160,17 +160,17 @@ namespace kiwano
{
// 需要计算比率
// 最高像素 14最宽像素 41增量为 1/64
float pixel_asp_ratio = (prop_val.bVal + 15.f) / 64.f;
Float32 pixel_asp_ratio = (prop_val.bVal + 15.f) / 64.f;
// 根据像素长宽比计算像素中的图像宽度和高度,只缩小图像
if (pixel_asp_ratio > 1.f)
{
width_in_pixels_ = width;
height_in_pixels_ = static_cast<unsigned int>(height / pixel_asp_ratio);
height_in_pixels_ = static_cast<UInt32>(height / pixel_asp_ratio);
}
else
{
width_in_pixels_ = static_cast<unsigned int>(width * pixel_asp_ratio);
width_in_pixels_ = static_cast<UInt32>(width * pixel_asp_ratio);
height_in_pixels_ = height;
}
}
@ -193,7 +193,7 @@ namespace kiwano
{
BYTE bg_index = 0;
WICColor bgcolors[256];
UINT colors_copied = 0;
UInt32 colors_copied = 0;
ComPtr<IWICPalette> wic_palette;
PROPVARIANT prop_val;
@ -249,13 +249,13 @@ namespace kiwano
if (SUCCEEDED(hr))
{
// 转换为 ARGB 格式
float alpha = (bgcolors[bg_index] >> 24) / 255.f;
Float32 alpha = (bgcolors[bg_index] >> 24) / 255.f;
bg_color_ = Color(bgcolors[bg_index], alpha);
}
return hr;
}
HRESULT GifImage::GetRawFrame(UINT frame_index, Image& raw_frame, Rect& frame_rect, Duration& delay, DisposalType& disposal_type)
HRESULT GifImage::GetRawFrame(UInt32 frame_index, Image& raw_frame, Rect& frame_rect, Duration& delay, DisposalType& disposal_type)
{
ComPtr<IWICFormatConverter> converter;
ComPtr<IWICBitmapFrameDecode> wic_frame;
@ -317,7 +317,7 @@ namespace kiwano
hr = (prop_val.vt == VT_UI2 ? S_OK : E_FAIL);
if (SUCCEEDED(hr))
{
frame_rect.origin.x = static_cast<float>(prop_val.uiVal);
frame_rect.origin.x = static_cast<Float32>(prop_val.uiVal);
}
PropVariantClear(&prop_val);
}
@ -331,7 +331,7 @@ namespace kiwano
hr = (prop_val.vt == VT_UI2 ? S_OK : E_FAIL);
if (SUCCEEDED(hr))
{
frame_rect.origin.y = static_cast<float>(prop_val.uiVal);
frame_rect.origin.y = static_cast<Float32>(prop_val.uiVal);
}
PropVariantClear(&prop_val);
}
@ -345,7 +345,7 @@ namespace kiwano
hr = (prop_val.vt == VT_UI2 ? S_OK : E_FAIL);
if (SUCCEEDED(hr))
{
frame_rect.size.x = static_cast<float>(prop_val.uiVal);
frame_rect.size.x = static_cast<Float32>(prop_val.uiVal);
}
PropVariantClear(&prop_val);
}
@ -359,7 +359,7 @@ namespace kiwano
hr = (prop_val.vt == VT_UI2 ? S_OK : E_FAIL);
if (SUCCEEDED(hr))
{
frame_rect.size.y = static_cast<float>(prop_val.uiVal);
frame_rect.size.y = static_cast<Float32>(prop_val.uiVal);
}
PropVariantClear(&prop_val);
}
@ -375,7 +375,7 @@ namespace kiwano
if (SUCCEEDED(hr))
{
UINT udelay = 0;
UInt32 udelay = 0;
hr = UIntMult(prop_val.uiVal, 10, &udelay);
if (SUCCEEDED(hr))
{

View File

@ -39,11 +39,11 @@ namespace kiwano
bool IsValid() const;
inline UINT GetWidthInPixels() const { return width_in_pixels_; }
inline UInt32 GetWidthInPixels() const { return width_in_pixels_; }
inline UINT GetHeightInPixels() const { return height_in_pixels_; }
inline UInt32 GetHeightInPixels() const { return height_in_pixels_; }
inline UINT GetFramesCount() const { return frames_count_; }
inline UInt32 GetFramesCount() const { return frames_count_; }
inline Color GetBackgroundColor() const { return bg_color_; }
@ -57,7 +57,7 @@ namespace kiwano
};
HRESULT GetRawFrame(
UINT frame_index,
UInt32 frame_index,
Image& raw_frame,
Rect& frame_rect,
Duration& delay,
@ -76,9 +76,9 @@ namespace kiwano
);
protected:
UINT frames_count_;
UINT width_in_pixels_;
UINT height_in_pixels_;
UInt32 frames_count_;
UInt32 width_in_pixels_;
UInt32 height_in_pixels_;
Color bg_color_;
ComPtr<IWICBitmapDecoder> decoder_;

View File

@ -64,7 +64,7 @@ namespace kiwano
return bitmap_ != nullptr;
}
float Image::GetWidth() const
Float32 Image::GetWidth() const
{
if (bitmap_)
{
@ -73,7 +73,7 @@ namespace kiwano
return 0;
}
float Image::GetHeight() const
Float32 Image::GetHeight() const
{
if (bitmap_)
{
@ -92,7 +92,7 @@ namespace kiwano
return Size{};
}
UINT32 Image::GetWidthInPixels() const
UInt32 Image::GetWidthInPixels() const
{
if (bitmap_)
{
@ -101,7 +101,7 @@ namespace kiwano
return 0;
}
UINT32 Image::GetHeightInPixels() const
UInt32 Image::GetHeightInPixels() const
{
if (bitmap_)
{
@ -110,14 +110,14 @@ namespace kiwano
return 0;
}
math::Vec2T<UINT32> Image::GetSizeInPixels() const
math::Vec2T<UInt32> Image::GetSizeInPixels() const
{
if (bitmap_)
{
auto bitmap_size = bitmap_->GetPixelSize();
return math::Vec2T<UINT32>{ bitmap_size.width, bitmap_size.height };
return math::Vec2T<UInt32>{ bitmap_size.width, bitmap_size.height };
}
return math::Vec2T<UINT32>{};
return math::Vec2T<UInt32>{};
}
void Image::CopyFrom(Image const& copy_from)
@ -135,13 +135,13 @@ namespace kiwano
if (IsValid() && copy_from.IsValid())
{
HRESULT hr = bitmap_->CopyFromBitmap(
&D2D1::Point2U(UINT(dest_point.x), UINT(dest_point.y)),
&D2D1::Point2U(UInt32(dest_point.x), UInt32(dest_point.y)),
copy_from.GetBitmap().get(),
&D2D1::RectU(
UINT(src_rect.GetLeft()),
UINT(src_rect.GetTop()),
UINT(src_rect.GetRight()),
UINT(src_rect.GetBottom()))
UInt32(src_rect.GetLeft()),
UInt32(src_rect.GetTop()),
UInt32(src_rect.GetRight()),
UInt32(src_rect.GetBottom()))
);
ThrowIfFailed(hr);

View File

@ -57,22 +57,22 @@ namespace kiwano
bool IsValid() const;
// 获取位图宽度
float GetWidth() const;
Float32 GetWidth() const;
// 获取位图高度
float GetHeight() const;
Float32 GetHeight() const;
// 获取位图大小
Size GetSize() const;
// 获取位图像素宽度
UINT32 GetWidthInPixels() const;
UInt32 GetWidthInPixels() const;
// 获取位图像素高度
UINT32 GetHeightInPixels() const;
UInt32 GetHeightInPixels() const;
// 获取位图像素大小
math::Vec2T<UINT32> GetSizeInPixels() const;
math::Vec2T<UInt32> GetSizeInPixels() const;
// 拷贝位图内存
void CopyFrom(Image const& copy_from);

View File

@ -25,7 +25,7 @@
namespace kiwano
{
template <typename _Ty, typename _PathTy, typename _CacheTy>
_Ty CreateOrGetCache(_CacheTy& cache, _PathTy const& path, size_t hash)
_Ty CreateOrGetCache(_CacheTy& cache, _PathTy const& path, UInt32 hash)
{
auto iter = cache.find(hash);
if (iter != cache.end())
@ -42,7 +42,7 @@ namespace kiwano
}
template <typename _CacheTy>
void RemoveCache(_CacheTy& cache, size_t hash)
void RemoveCache(_CacheTy& cache, UInt32 hash)
{
auto iter = cache.find(hash);
if (iter != cache.end())

View File

@ -48,10 +48,10 @@ namespace kiwano
virtual ~ImageCache();
protected:
using ImageMap = UnorderedMap<size_t, Image>;
using ImageMap = UnorderedMap<UInt32, Image>;
ImageMap image_cache_;
using GifImageMap = UnorderedMap<size_t, GifImage>;
using GifImageMap = UnorderedMap<UInt32, GifImage>;
GifImageMap gif_image_cache_;
};
}

View File

@ -37,9 +37,9 @@ namespace kiwano
inline void SetAreaRect(Rect const& area) { area_ = area; }
inline float GetOpacity() const { return opacity_; }
inline Float32 GetOpacity() const { return opacity_; }
inline void SetOpacity(float opacity) { opacity_ = opacity; }
inline void SetOpacity(Float32 opacity) { opacity_ = opacity; }
inline Geometry const& GetMaskGeometry() const { return mask_; }
@ -52,7 +52,7 @@ namespace kiwano
protected:
Rect area_;
float opacity_;
Float32 opacity_;
Geometry mask_;
ComPtr<ID2D1Layer> layer_;
};

View File

@ -106,7 +106,7 @@ namespace kiwano
void RenderTarget::DrawGeometry(
Geometry const& geometry,
Color const& stroke_color,
float stroke_width,
Float32 stroke_width,
StrokeStyle stroke
) const
{
@ -153,7 +153,7 @@ namespace kiwano
ThrowIfFailed(hr);
}
void RenderTarget::DrawLine(Point const& point1, Point const& point2, Color const& stroke_color, float stroke_width, StrokeStyle stroke) const
void RenderTarget::DrawLine(Point const& point1, Point const& point2, Color const& stroke_color, Float32 stroke_width, StrokeStyle stroke) const
{
HRESULT hr = S_OK;
if (!solid_color_brush_ || !render_target_)
@ -179,7 +179,7 @@ namespace kiwano
ThrowIfFailed(hr);
}
void RenderTarget::DrawRectangle(Rect const& rect, Color const& stroke_color, float stroke_width, StrokeStyle stroke) const
void RenderTarget::DrawRectangle(Rect const& rect, Color const& stroke_color, Float32 stroke_width, StrokeStyle stroke) const
{
HRESULT hr = S_OK;
if (!solid_color_brush_ || !render_target_)
@ -224,7 +224,7 @@ namespace kiwano
ThrowIfFailed(hr);
}
void RenderTarget::DrawRoundedRectangle(Rect const& rect, Vec2 const& radius, Color const& stroke_color, float stroke_width, StrokeStyle stroke) const
void RenderTarget::DrawRoundedRectangle(Rect const& rect, Vec2 const& radius, Color const& stroke_color, Float32 stroke_width, StrokeStyle stroke) const
{
HRESULT hr = S_OK;
if (!solid_color_brush_ || !render_target_)
@ -277,7 +277,7 @@ namespace kiwano
ThrowIfFailed(hr);
}
void RenderTarget::DrawEllipse(Point const& center, Vec2 const& radius, Color const& stroke_color, float stroke_width, StrokeStyle stroke) const
void RenderTarget::DrawEllipse(Point const& center, Vec2 const& radius, Color const& stroke_color, Float32 stroke_width, StrokeStyle stroke) const
{
HRESULT hr = S_OK;
if (!solid_color_brush_ || !render_target_)
@ -516,7 +516,7 @@ namespace kiwano
ThrowIfFailed(hr);
}
float RenderTarget::GetOpacity() const
Float32 RenderTarget::GetOpacity() const
{
return opacity_;
}
@ -537,7 +537,7 @@ namespace kiwano
ThrowIfFailed(hr);
}
void RenderTarget::SetOpacity(float opacity)
void RenderTarget::SetOpacity(Float32 opacity)
{
HRESULT hr = S_OK;
if (!solid_color_brush_)

View File

@ -44,7 +44,7 @@ namespace kiwano
void DrawGeometry(
Geometry const& geometry,
Color const& stroke_color,
float stroke_width,
Float32 stroke_width,
StrokeStyle stroke = StrokeStyle::Miter
) const;
@ -57,14 +57,14 @@ namespace kiwano
Point const& point1,
Point const& point2,
Color const& stroke_color,
float stroke_width,
Float32 stroke_width,
StrokeStyle stroke = StrokeStyle::Miter
) const;
void DrawRectangle(
Rect const& rect,
Color const& stroke_color,
float stroke_width,
Float32 stroke_width,
StrokeStyle stroke = StrokeStyle::Miter
) const;
@ -77,7 +77,7 @@ namespace kiwano
Rect const& rect,
Vec2 const& radius,
Color const& stroke_color,
float stroke_width,
Float32 stroke_width,
StrokeStyle stroke = StrokeStyle::Miter
) const;
@ -91,7 +91,7 @@ namespace kiwano
Point const& center,
Vec2 const& radius,
Color const& stroke_color,
float stroke_width,
Float32 stroke_width,
StrokeStyle stroke = StrokeStyle::Miter
) const;
@ -136,10 +136,10 @@ namespace kiwano
Color const& clear_color
);
float GetOpacity() const;
Float32 GetOpacity() const;
void SetOpacity(
float opacity
Float32 opacity
);
void SetTransform(
@ -159,7 +159,7 @@ namespace kiwano
public:
struct Status
{
int primitives;
Int32 primitives;
Time start;
Duration duration;
};
@ -183,7 +183,7 @@ namespace kiwano
bool IsValid() const;
protected:
float opacity_;
Float32 opacity_;
bool antialias_;
mutable bool collecting_status_;
mutable Status status_;

View File

@ -191,14 +191,14 @@ namespace kiwano
ThrowIfFailed(hr);
}
void Renderer::HandleMessage(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
void Renderer::HandleMessage(HWND hwnd, UInt32 msg, WPARAM wparam, LPARAM lparam)
{
switch (msg)
{
case WM_SIZE:
{
UINT width = LOWORD(lparam);
UINT height = HIWORD(lparam);
UInt32 width = LOWORD(lparam);
UInt32 height = HIWORD(lparam);
Resize(width, height);
break;
@ -390,7 +390,7 @@ namespace kiwano
if (SUCCEEDED(hr))
{
LPVOID collection_key = nullptr;
UINT32 collection_key_size = 0;
UInt32 collection_key_size = 0;
hr = font_collection_loader_->AddFilePaths(file_paths, &collection_key, &collection_key_size);
@ -428,7 +428,7 @@ namespace kiwano
if (SUCCEEDED(hr))
{
LPVOID collection_key = nullptr;
UINT32 collection_key_size = 0;
UInt32 collection_key_size = 0;
hr = res_font_collection_loader_->AddResources(res_arr, &collection_key, &collection_key_size);
@ -667,7 +667,7 @@ namespace kiwano
vsync_ = enabled;
}
void Renderer::Resize(UINT width, UINT height)
void Renderer::Resize(UInt32 width, UInt32 height)
{
HRESULT hr = S_OK;
if (!d3d_res_)
@ -677,8 +677,8 @@ namespace kiwano
if (SUCCEEDED(hr))
{
output_size_.x = static_cast<float>(width);
output_size_.y = static_cast<float>(height);
output_size_.x = static_cast<Float32>(width);
output_size_.y = static_cast<Float32>(height);
hr = d3d_res_->SetLogicalSize(output_size_);
}

Some files were not shown because too many files have changed in this diff Show More