-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc964de
commit a2d4367
Showing
5 changed files
with
50 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,43 @@ | ||
#pragma once | ||
#include <functional> | ||
#include <SFML/System/Vector2.hpp> | ||
#include "editor/transition.hpp" | ||
|
||
|
||
struct ControlState | ||
{ | ||
using ViewAction = std::function<void(sf::Vector2f)>; | ||
using Action = std::function<void(void)>; | ||
|
||
Action action = nullptr; | ||
ViewAction view_action = nullptr; | ||
// Special commands | ||
bool focus_requested = false; | ||
trn::Transition<sf::Vector2f> focus; | ||
trn::Transition<float> zoom = 1.0f; | ||
|
||
ControlState() | ||
{ | ||
} | ||
|
||
void executeViewAction(sf::Vector2f mouse_world_position) | ||
{ | ||
if (view_action) { | ||
view_action(mouse_world_position); | ||
} | ||
} | ||
|
||
void executeAction(sf::Vector2f mouse_world_position) | ||
{ | ||
if (action) { | ||
action(); | ||
} | ||
} | ||
|
||
void requestFocus(sf::Vector2f position, float zoom_level = 1.0f) | ||
{ | ||
focus_requested = true; | ||
focus = position; | ||
zoom = zoom_level; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters