mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-25 11:52:40 +01:00
Add Weapon debug menu
This commit is contained in:
parent
e83201b45b
commit
a08f20dd5b
@ -5,6 +5,8 @@
|
||||
#include <objects/InstanceObject.hpp>
|
||||
#include <objects/VehicleObject.hpp>
|
||||
#include <engine/GameState.hpp>
|
||||
#include <items/InventoryItem.hpp>
|
||||
#include <data/WeaponData.hpp>
|
||||
#include <sstream>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
#include <glm/gtx/string_cast.hpp>
|
||||
@ -95,6 +97,9 @@ Menu* DebugState::createDebugMenu()
|
||||
m->addEntry(Menu::lambda("-AI", [=] {
|
||||
this->enterMenu(createAIMenu());
|
||||
}, kDebugEntryHeight));
|
||||
m->addEntry(Menu::lambda("-Weapons", [=] {
|
||||
this->enterMenu(createWeaponMenu());
|
||||
}, kDebugEntryHeight));
|
||||
|
||||
m->addEntry(Menu::lambda("Set Super Jump", [=] {
|
||||
player->setJumpSpeed(20.f);
|
||||
@ -287,6 +292,26 @@ Menu* DebugState::createAIMenu()
|
||||
return m;
|
||||
}
|
||||
|
||||
Menu*DebugState::createWeaponMenu()
|
||||
{
|
||||
Menu* m = new Menu(2);
|
||||
m->offset = kDebugMenuOffset;
|
||||
|
||||
m->addEntry(Menu::lambda("Back", [=] {
|
||||
this->enterMenu(createDebugMenu());
|
||||
}, kDebugEntryHeight));
|
||||
|
||||
for (int i = 1; i < maxInventorySlots; ++i) {
|
||||
auto item = getWorld()->getInventoryItem(i);
|
||||
auto& name = getWorld()->data->weaponData[i]->name;
|
||||
m->addEntry(Menu::lambda(name, [=] {
|
||||
giveItem(item);
|
||||
}, kDebugEntryHeight));
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
DebugState::DebugState(RWGame* game, const glm::vec3& vp, const glm::quat& vd)
|
||||
: State(game)
|
||||
, _freeLook( false )
|
||||
@ -467,6 +492,22 @@ void DebugState::spawnFollower(unsigned int id)
|
||||
}
|
||||
}
|
||||
|
||||
void DebugState::giveItem(InventoryItem* item)
|
||||
{
|
||||
CharacterObject* player = nullptr;
|
||||
if (game->getPlayer()) {
|
||||
player = game->getPlayer()->getCharacter();
|
||||
}
|
||||
|
||||
if (player) {
|
||||
player->addToInventory(item);
|
||||
auto& wep =
|
||||
player->getCurrentState().weapons[item->getInventorySlot()];
|
||||
wep.bulletsTotal = 100;
|
||||
wep.bulletsClip = 0;
|
||||
}
|
||||
}
|
||||
|
||||
const ViewCamera &DebugState::getCamera()
|
||||
{
|
||||
return _debugCam;
|
||||
|
@ -15,6 +15,7 @@ class DebugState : public State
|
||||
Menu* createMapMenu();
|
||||
Menu* createVehicleMenu();
|
||||
Menu* createAIMenu();
|
||||
Menu* createWeaponMenu();
|
||||
public:
|
||||
DebugState(RWGame* game, const glm::vec3& vp = {}, const glm::quat& vd = {});
|
||||
|
||||
@ -30,6 +31,7 @@ public:
|
||||
|
||||
void spawnVehicle(unsigned int id);
|
||||
void spawnFollower(unsigned int id);
|
||||
void giveItem(InventoryItem* item);
|
||||
|
||||
const ViewCamera& getCamera();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user