Skip to content

Commit

Permalink
Updated menu files
Browse files Browse the repository at this point in the history
  • Loading branch information
Danilo1301 committed Oct 20, 2024
1 parent f88ddd6 commit 1b8fb00
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 51 deletions.
Binary file added files/texturas luzes/backup/coronaheadlightline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added files/texturas luzes/backup/coronareflect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added files/texturas luzes/backup/coronaringb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 0 additions & 42 deletions include/SimpleGTA.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,48 +126,6 @@ class CPed : public CPlaceable {};
class CVehicle : public CEntity {};
class CObject : public CPlaceable {};

struct GTAVector3D
{
float x, y, z;
float SqrMagnitude() { return x * x + y * y + z * z; }
inline GTAVector3D operator-(const GTAVector3D& v) { return { x - v.x, y - v.y, z - v.z }; }
};
struct GTAMatrix
{
GTAVector3D right;
unsigned int flags;
GTAVector3D up;
unsigned int pad1;
GTAVector3D at;
unsigned int pad2;
GTAVector3D pos;
unsigned int pad3;

void* ptr;
bool bln;
};
struct tByteFlag
{
uint8_t nId : 7;
bool bEmpty : 1;
};
struct GTAEntity
{
inline int AsInt() { return (int)this; }
inline int& IntAt(int off) { return *(int*)(AsInt() + off); }
inline uint32_t& UIntAt(int off) { return *(uint32_t*)(AsInt() + off); }
inline uint8_t& UInt8At(int off) { return *(uint8_t*)(AsInt() + off); }
inline GTAVector3D& GetPos()
{
GTAMatrix* matrix = *(GTAMatrix**)(AsInt() + 20);
return matrix ? matrix->pos : *(GTAVector3D*)(AsInt() + 4);
}
};
struct GTAVehicleSA : GTAEntity
{
char structure[2604];
};

static RwFrame* GetObjectParent(RwObject *obj) {
return reinterpret_cast<RwFrame *>(rwObjectGetParent(obj));
}
4 changes: 2 additions & 2 deletions include/menu/IDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

class IDebug {
public:
std::vector<std::string> m_Lines;
bool m_Visible = false;
std::vector<std::string> lines;
bool visible = false;

virtual void AddLine(std::string text) = 0;
virtual void Clear() = 0;
Expand Down
40 changes: 39 additions & 1 deletion include/menu/IMenuVSL.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@

#include <iostream>
#include <vector>
#include <map>

#include "SimpleGTA.h"
#include "MenuStructs.h"

#include "IWindow.h"
#include "IDebug.h"

#define _debug menuVSL->debug

class IMenuVSL {
public:
IDebug* debug = NULL;
unsigned int deltaTime = 0;

/*1.0.0*/

virtual IWindow* AddWindow() = 0;
virtual std::vector<IWindow*> GetWindows() = 0;

Expand All @@ -23,12 +28,45 @@ class IMenuVSL {
virtual void DrawRectWithString(std::string text, CVector2D pos, CVector2D boxSize, CRGBA boxColor, CRGBA textColor, eFontAlignment align) = 0;

/*1.1.0*/

virtual void DrawSprite(CSprite2d* sprite, CVector2D pos, CVector2D size) = 0;
virtual void* LoadRwTextureFromFile(std::string file, std::string textureName, bool flipHorizontal = false);

/*
* Load RwTexture* from a file (tested with a .png)
*/
virtual void* LoadRwTextureFromFile(std::string file, std::string textureName, bool flipHorizontal = false);

virtual IWindow* AddWindowOptionsString(std::string title, IWindow* parent, std::string* pString, std::vector<std::string>* options) = 0;
virtual IWindow* AddWindowMultiOptionsString(std::string title, IWindow* parent, std::vector<std::string>* selectedOptions, std::vector<std::string>* allOptions) = 0;
virtual IWindow* AddColorWindow(IWindow* parent, CRGBA* color, std::function<void()> onValueChange) = 0;

/*1.2.0*/

virtual void SetGlobalIntVariable(std::string key, int value) = 0;
virtual int GetGlobalIntVariable(std::string key) = 0;

virtual CVector2D ConvertWorldPositionToScreenPosition(CVector worldPosition) = 0;
virtual void DrawWorldText(std::string text, CVector position, CRGBA color, eFontAlignment align) = 0;
virtual void AddOnRender(std::function<void()> fn) = 0;
virtual void SetFontScale(float sx, float sy) = 0;
virtual CVector2D GetFontScale() = 0;
virtual void ResetFontScale() = 0;

/*1.3.0*/

virtual void AddOnVehicleRenderBefore(std::function<void(void*)> fn) = 0;
virtual void AddOnVehicleRenderAfter(std::function<void(void*)> fn) = 0;
virtual void AddOnUpdate(std::function<void()> fn) = 0;
virtual void AddOnProcessScripts(std::function<void()> fn) = 0;
virtual std::vector<MVehicle> GetVehicles() = 0;

virtual void DrawRectWithStringMultiline(std::string text, CVector2D pos, float width, CVector2D padding, CRGBA boxColor, CRGBA textColor, eFontAlignment align) = 0;
virtual void ShowPopup(std::string title, std::string text, CVector2D pos, int time) = 0;

// default value for drawWithFixedScale is true
// using false is usefull with ConvertWorldPositionToScreenPosition
virtual void SetDrawWithFixedScale(bool enabled) = 0;

virtual IWindow* AddVector2Window(IWindow* parent, CVector2D* vec, float min, float max, float addBy) = 0;
virtual IWindow* AddVectorWindow(IWindow* parent, CVector* vec, float min, float max, float addBy) = 0;
};
15 changes: 15 additions & 0 deletions include/menu/IPopup.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma once

#include <iostream>

#include "SimpleGTA.h"

#include "IItem.h"

class IPopup {
public:
CVector2D m_Position = CVector2D(400, 200);
std::vector<IItem*> m_Items;
std::string m_Title = "Popup";
std::string m_Text = "Text";
};
4 changes: 3 additions & 1 deletion include/menu/IWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
class IWindow {
public:
int m_Id = -1;
CVector2D m_Position = CVector2D(200, 200);
CVector2D m_Position = CVector2D(400, 200);
std::vector<IItem*> m_Items;
std::string m_Title = "Window";
float m_Width = 500.0f;
CRGBA m_TitleBackgroundColor = CRGBA(0, 100, 200);
CRGBA m_SubTitleBackgroundColor = CRGBA(0, 0, 0);
CRGBA m_ItemBackgroundColor = CRGBA(0, 0, 0, 100);
int m_Page = 0;
int m_MaxItemsPerPage = 7;
Expand All @@ -25,6 +26,7 @@ class IWindow {
virtual void SetPosition(CVector2D position) = 0;
virtual IItem* AddText(std::string text, CRGBA color) = 0;
virtual IItem* AddButton(std::string text, CRGBA color) = 0;
virtual IItem* AddButton(std::string text) = 0;
virtual IItem* AddCheckbox(std::string text, bool* value) = 0;
virtual IItem* AddIntRange(std::string text, int* value, int min, int max, int addBy) = 0;
virtual IItem* AddFloatRange(std::string text, float* value, float min, float max, float addBy) = 0;
Expand Down
6 changes: 6 additions & 0 deletions include/menu/MenuStructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
#include <iostream>
#include <string>

struct MVehicle
{
int hVehicle;
void* pVehicle;
};

static unsigned char ucharIntensity(unsigned char uc, float intensity)
{
return (unsigned char)std::clamp((int)round(((float)uc) * intensity), 0, 255);
Expand Down
95 changes: 90 additions & 5 deletions include/menu/SimpleGTA.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <stdint.h>

class CVector {
public:
float x = 0.0f;
Expand All @@ -13,6 +15,37 @@ class CVector {
this->z = z;
}

inline void operator=(const CVector& right){
x = right.x;
y = right.y;
z = right.z;
}

inline void operator+=(const CVector& right) {
x = right.x + x;
y = right.y + y;
z = right.z + z;
}

inline void operator-=(const CVector& right) {
x = x - right.x;
y = y - right.y;
z = z - right.z;
}

inline void operator*=(float multiplier) {
x = multiplier * x;
y = multiplier * y;
z = multiplier * z;
}

inline void operator/=(float divisor) {
float a = 1.0 / divisor;
x = a * x;
y = a * y;
z = a * z;
}

CVector operator+(const CVector right)
{
CVector result(this->x, this->y, this->z);
Expand Down Expand Up @@ -78,16 +111,16 @@ class CRGBA {
class CRect {
public:
float left = 0; // x1
float bottom = 0; // y1
float top = 0; // y1
float right = 0; // x2
float top = 0; // y2
float bottom = 0; // y2

CRect(float left, float bottom, float right, float top)
CRect(float left, float top, float right, float bottom)
{
this->left = left;
this->bottom = bottom;
this->right = right;
this->top = top;
this->right = right;
this->bottom = bottom;
}
};

Expand Down Expand Up @@ -118,4 +151,56 @@ enum eFontStyle : unsigned char {
FONT_SUBTITLES,
FONT_MENU,
FONT_PRICEDOWN
};

struct GTAVector3D
{
float x, y, z;
float SqrMagnitude() { return x * x + y * y + z * z; }
inline GTAVector3D operator-(const GTAVector3D& v) { return { x - v.x, y - v.y, z - v.z }; }
};

struct GTAMatrix
{
GTAVector3D right;
unsigned int flags;
GTAVector3D up;
unsigned int pad1;
GTAVector3D at;
unsigned int pad2;
GTAVector3D pos;
unsigned int pad3;

void* ptr;
bool bln;
};

struct tByteFlag
{
uint8_t nId : 7;
bool bEmpty : 1;
};

struct GTAEntity
{
inline int AsInt() { return (int)this; }
inline int& IntAt(int off) { return *(int*)(AsInt() + off); }
inline uint32_t& UIntAt(int off) { return *(uint32_t*)(AsInt() + off); }
inline uint8_t& UInt8At(int off) { return *(uint8_t*)(AsInt() + off); }
inline GTAVector3D& GetPos()
{
GTAMatrix* matrix = *(GTAMatrix**)(AsInt() + 20);
return matrix ? matrix->pos : *(GTAVector3D*)(AsInt() + 4);
}
};

struct GTAVehicleSA : GTAEntity
{
char structure[2604];
};

struct GTAPedSA : GTAEntity
{
char structure[1996];
bool Player() { return UIntAt(1436) < 2; }
};

0 comments on commit 1b8fb00

Please sign in to comment.