45 lines
950 B
C++
45 lines
950 B
C++
/**
|
|
* @file dl_tool_ctrl_2d.h
|
|
* @brief 2d地图控制器
|
|
*
|
|
*
|
|
* @version 1.0
|
|
* @author lveyou
|
|
* @date 25-07-16
|
|
*
|
|
* @note 通用的2d地图操作控制器
|
|
*/
|
|
#pragma once
|
|
|
|
#ifndef DL_DISABLE_RENDER
|
|
#include "dl_type.h"
|
|
#include "io/dl_input.h"
|
|
#include "misc/dl_component_use.h"
|
|
|
|
namespace dl::Tool
|
|
{
|
|
//! 2d地图控制器,例如平移、缩放等操作
|
|
class Controller2d
|
|
{
|
|
public:
|
|
bool _bMoveWasd = true;
|
|
float _moveSpeed = 400.0f;
|
|
float _moveSpeedShift = 2.0f;
|
|
|
|
bool _bScaleWheel = true;
|
|
float _scaleSpeed = 5.0f;
|
|
Position _scaleRange = { 0.25f, 2.0f };
|
|
bool _bScaleWithMouse = true; // 随鼠标位置缩放,否则以窗口中心缩放
|
|
std::vector<float> _scaleLevel; // 不为空时使用
|
|
size_t _scaleLevelCur = 0;
|
|
MouseCode _keyDrag = MouseCode::MIDDLE;
|
|
|
|
void Update(Coor* coor);
|
|
// 传入地图大小,限制地图在窗口内
|
|
void UpdateLimit(Coor* coor, const Size& map_size);
|
|
private:
|
|
Cpt::Drag _drag;
|
|
};
|
|
|
|
}
|
|
#endif |