居中显示位置修正
This commit is contained in:
+2
-18
@@ -60,6 +60,8 @@ public:
|
||||
|
||||
/**
|
||||
* @brief 将点 从 自身坐标系 转到 父坐标系
|
||||
*
|
||||
* @note 注意 coor->ThisToParent(pos)和 pos * coor->GetScale()的效果不同
|
||||
*/
|
||||
Position ThisToParent(Position pos) const;
|
||||
|
||||
@@ -77,24 +79,6 @@ public:
|
||||
* @brief 将点 从 自身坐标系 转到 根坐标系
|
||||
*/
|
||||
Position ThisToRoot(Position pos) const;
|
||||
|
||||
|
||||
/**
|
||||
* @brief 将点 从 世界坐标系 转到 父坐标系
|
||||
*/
|
||||
Position WorldToParent(Position pos) const
|
||||
{
|
||||
return _parent ? _parent->WorldToThis(pos) : WorldToThis(pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 将点 从 父坐标系 转到 世界坐标系
|
||||
*/
|
||||
Position ParentToWorld(Position pos) const
|
||||
{
|
||||
return _parent ? _parent->ThisToWorld(pos) : ThisToWorld(pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 获取它的根坐标系
|
||||
* @retval 返回对应根坐标系的指针,如果是窗口坐标系,返回nullptr
|
||||
|
||||
@@ -108,6 +108,13 @@ public:
|
||||
*/
|
||||
Size GetWindowSize();
|
||||
/**
|
||||
* @brief 返回窗口中心
|
||||
*/
|
||||
Position GetWindowCenter()
|
||||
{
|
||||
return toPosition(GetWindowSize()) * 0.5f;
|
||||
}
|
||||
/**
|
||||
* @brief 获取桌面大小,不包含任务栏
|
||||
*/
|
||||
Size GetWorkArea();
|
||||
|
||||
@@ -93,5 +93,16 @@ void Controller2d::UpdateLimit(Coor* coor, const Size& map_size)
|
||||
coor->SetPosition(pos);
|
||||
}
|
||||
|
||||
void Controller2d::Center(Coor* coor, const Position& pos, size_t scale_level)
|
||||
{
|
||||
// 先修改缩放
|
||||
_scaleLevelCur = std::clamp(scale_level, (size_t)0, _scaleLevel.size() - 1);
|
||||
coor->SetScale(_scaleLevel[_scaleLevelCur]);
|
||||
|
||||
Position p1 = pos * coor->GetScale();
|
||||
Position p2 = g_system->GetWindowCenter();
|
||||
coor->SetPosition(p2 - p1);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
@@ -37,6 +37,8 @@ public:
|
||||
void Update(Coor* coor);
|
||||
// 传入地图大小,限制地图在窗口内
|
||||
void UpdateLimit(Coor* coor, const Size& map_size);
|
||||
// 将位置(地图坐标系)设为中心
|
||||
void Center(Coor* coor, const Position& pos, size_t scale_level);
|
||||
private:
|
||||
Cpt::Drag _drag;
|
||||
};
|
||||
|
||||
+1
-1
Submodule project/dl_config updated: 87e3d8fffe...f7a8db5f48
+1
-1
Submodule project/hs updated: 08eebd1bea...7188310de3
Reference in New Issue
Block a user