76 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			C++
		
	
	
	
			
		
		
	
	
			76 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			C++
		
	
	
	
// Copyright (c) 2016-2018 Easy2D - Nomango
 | 
						|
// 
 | 
						|
// Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
						|
// of this software and associated documentation files (the "Software"), to deal
 | 
						|
// in the Software without restriction, including without limitation the rights
 | 
						|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
						|
// copies of the Software, and to permit persons to whom the Software is
 | 
						|
// furnished to do so, subject to the following conditions:
 | 
						|
// 
 | 
						|
// The above copyright notice and this permission notice shall be included in
 | 
						|
// all copies or substantial portions of the Software.
 | 
						|
// 
 | 
						|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
						|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
						|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
						|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
						|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
						|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
						|
// THE SOFTWARE.
 | 
						|
 | 
						|
#pragma once
 | 
						|
#include "macros.h"
 | 
						|
 | 
						|
namespace easy2d
 | 
						|
{
 | 
						|
	// 资源数据
 | 
						|
	// 
 | 
						|
	// Usage:
 | 
						|
	//     如果需要手动加载资源, 可以通过 Resource::Load 方法获取资源内容
 | 
						|
	//     ResourceData data;
 | 
						|
	//     if (res.Load(&data)) {
 | 
						|
	//         LPVOID data = data.buffer;
 | 
						|
	//         DWORD size = data.buffer_size;
 | 
						|
	//     }
 | 
						|
	//
 | 
						|
	struct ResourceData
 | 
						|
	{
 | 
						|
		LPVOID buffer;
 | 
						|
		DWORD buffer_size;
 | 
						|
	};
 | 
						|
 | 
						|
 | 
						|
	// 资源
 | 
						|
	// 
 | 
						|
	// Usage:
 | 
						|
	//     Resource 用于获取可执行文件 (exe) 中的资源, 必须在构造函数中指定它的
 | 
						|
	//     资源类型和名称标识符。
 | 
						|
	//     例如, 一份音频资源的类型为 L"WAVE", 名称标识符为 IDR_WAVE_1,
 | 
						|
	//     那么可以这样指定该资源: Resource res(MAKEINTRESOURCE(IDR_WAVE_1), L"WAVE");
 | 
						|
	// 
 | 
						|
	//     了解资源的更多信息: https://docs.microsoft.com/en-us/windows/desktop/menurc/resources
 | 
						|
	//
 | 
						|
	class Resource
 | 
						|
	{
 | 
						|
	public:
 | 
						|
		Resource(
 | 
						|
			LPCWSTR name,	/* 资源名称 */
 | 
						|
			LPCWSTR type	/* 资源类型 */
 | 
						|
		);
 | 
						|
 | 
						|
		bool Load(
 | 
						|
			ResourceData* buffer
 | 
						|
		) const;
 | 
						|
 | 
						|
		LPCWSTR	GetName() const;
 | 
						|
 | 
						|
		LPCWSTR	GetType() const;
 | 
						|
 | 
						|
		size_t GetHashCode() const;
 | 
						|
 | 
						|
	private:
 | 
						|
		LPCWSTR	name_;
 | 
						|
		LPCWSTR	type_;
 | 
						|
	};
 | 
						|
}
 |