feat(MainWindow): Added gravity gun

This commit is contained in:
Yimura 2021-05-19 16:05:21 +02:00
parent 29526040c7
commit 9e1465548b
No known key found for this signature in database
GPG Key ID: 3D8FF4397E768682
7 changed files with 65 additions and 3 deletions

View File

@ -1,4 +1,5 @@
#include "backend/looped/looped.hpp"
#include "core/enums.hpp"
#include "core/globals.hpp"
#include "util/entity.hpp"
#include "util/math.hpp"
@ -16,7 +17,7 @@ namespace big
void looped::weapons_gravity_gun()
{
bool bGravityGun = g.weapons.custom_weapon == 0;
bool bGravityGun = g.weapons.custom_weapon == CustomWeapons::GRAVITY_GUN;
double multiplier = 3.0;
if (bGravityGun)

View File

@ -0,0 +1,12 @@
#pragma once
#include "core/enums.hpp"
struct custom_weapon {
big::CustomWeapons id;
const char name[16];
};
const custom_weapon custom_weapons[] = {
{ big::CustomWeapons::NONE, "No weapon" },
{ big::CustomWeapons::GRAVITY_GUN, "Gravity Gun" }
};

View File

@ -0,0 +1,10 @@
#pragma once
namespace big
{
enum class CustomWeapons
{
NONE,
GRAVITY_GUN
};
}

View File

@ -1,4 +1,5 @@
#pragma once
#include "enums.hpp"
#ifndef GLOBALS_H
#define GLOBALS_H
@ -9,7 +10,7 @@ struct globals {
};
struct weapons {
int custom_weapon = -1;
big::CustomWeapons custom_weapon = big::CustomWeapons::NONE;
};
self self{};

View File

@ -0,0 +1,37 @@
#include "core/data/custom_weapons.hpp"
#include "core/globals.hpp"
#include "gui/window/main/tabs.hpp"
namespace big
{
void tab_main::tab_weapons()
{
if (ImGui::BeginTabItem("Weapons"))
{
if (ImGui::TreeNode("Custom Weapons"))
{
int selected = (int)g.weapons.custom_weapon;
if (ImGui::BeginCombo("Weapon", custom_weapons[selected].name))
{
for (custom_weapon weapon : custom_weapons)
{
if (ImGui::Selectable(weapon.name, weapon.id == (CustomWeapons)selected))
{
g.weapons.custom_weapon = weapon.id;
}
if (weapon.id == (CustomWeapons)selected)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
ImGui::TreePop();
}
ImGui::EndTabItem();
}
}
}

View File

@ -8,5 +8,6 @@ namespace big
public:
static void tab_self();
static void tab_spawn();
static void tab_weapons();
};
}

View File

@ -1,6 +1,5 @@
#include "gui/window.hpp"
#include "imgui.h"
#include "gui/base_tab.h"
#include "gui/window/main/tabs.hpp"
namespace big
@ -13,6 +12,7 @@ namespace big
ImGui::BeginTabBar("tabbar");
tab_main::tab_self();
tab_main::tab_spawn();
tab_main::tab_weapons();
ImGui::EndTabBar();
}
ImGui::End();