binds to choose between unit states

This commit is contained in:
devZoGok
2024-02-16 15:22:54 +02:00
parent 2948be04ee
commit 8bc9961359
5 changed files with 38 additions and 1 deletions
+3
View File
@@ -36,6 +36,9 @@ mappings = {
{bind = 32, trigger = 66, action = true, bindType = 0, inOptions = true},
{bind = 33, trigger = 256, action = true, bindType = 0, inOptions = true},
{bind = 47, trigger = 69, action = true, bindType = 0, inOptions = false},
{bind = 48, trigger = 84, action = true, bindType = 0, inOptions = false},
{bind = 49, trigger = 89, action = true, bindType = 0, inOptions = false},
{bind = 50, trigger = 85, action = true, bindType = 0, inOptions = false},
{bind = 7, trigger = 312, action = false, bindType = 2, inOptions = false},
{bind = 8, trigger = 313, action = false, bindType = 2, inOptions = false},
+15
View File
@@ -323,6 +323,12 @@ namespace battleship{
}
}
void ActiveGameState::enableUnitState(Unit::State state){
vector<Unit*> selectedUnits = mainPlayer->getSelectedUnits();
for(Unit *unit : selectedUnits)
unit->setState(state);
}
void ActiveGameState::onAction(int bind, bool isPressed) {
GameObjectFrameController *ufCtr = GameObjectFrameController::getSingleton();
@@ -416,6 +422,15 @@ namespace battleship{
}
break;
case Bind::ENABLE_CHASE_STATE:
enableUnitState(Unit::State::CHASE);
break;
case Bind::ENABLE_STAND_GROUND_STATE:
enableUnitState(Unit::State::STAND_GROUND);
break;
case Bind::ENABLE_HOLD_FIRE_STATE:
enableUnitState(Unit::State::HOLD_FIRE);
break;
case Bind::DESELECT:
if(ufCtr->isPlacingFrames()) ufCtr->setRotatingFrames(isPressed);
if (!isPressed) deselectUnits();
+1
View File
@@ -42,6 +42,7 @@ namespace battleship{
void castRayToTerrain();
void issueOrder(Order::TYPE, std::vector<Order::Target>, bool);
bool isInLineOfSight(vb01::Vector3, float, Unit*);
void enableUnitState(Unit::State);
inline bool canSelectHoveredOnGameObj(){return gameObjHoveredOn && gameObjHoveredOn->isSelectable() && gameObjHoveredOn->getPlayer() == mainPlayer;}
GuiAppState *guiState;
+4 -1
View File
@@ -50,7 +50,10 @@ namespace battleship{
CREATE_WATERBODY,
GENERATE_WEIGHTS,
TOGGLE_CELL_MARKERS,
EJECT_GARRISON
EJECT_GARRISON,
ENABLE_CHASE_STATE,
ENABLE_STAND_GROUND_STATE,
ENABLE_HOLD_FIRE_STATE
};
}
+15
View File
@@ -0,0 +1,15 @@
#ifndef MAP_LISTBOX_H
#define MAP_LISTBOX_H
#include <listbox.h>
namespace battleship{
class MapListbox : public vb01Gui::Listbox{
public:
MapListbox(vb01::Vector2, vb01::Vector2, std::vector<std::string>&, int, std::string, bool);
private:
void onClose();
};
}
#endif