Triditizer
cLTFX.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*LTFX Menu Advanced
4 s0beit & GHOSTER - created the first version of LTFX Menu
5 NeoIII - ReCoded full menu:
6 - added automated Item Settings loading and saving option.
7 - added possibility to add random count of 'describe' chars for addmenuitem func.
8 - added Menu Group system.
9 - added menuitem Hotkeys. ( i am not anymore sure if they was there on original version )
10 - added Drag&Drop funcionality.
11 - added navigation support for mouse & keys + handling keys with 'ProcKeyHook' ( SetWindowLong( ... ) on the Game Window )
12 - tweaked and changed here and there... you can look yourself...
13 Hans211 - Transparent Draw Functions ( i left them out here, sry )
14 Last Update - 01.01.2010 by NeoIII
15 Credits : http://www.unknowncheats.me/forum/c-and-c-/62587-tweaked-ltfx-menu-dx-8-9-a.html
16 Modified by samaust
17 */
18 
19 #include <d3d9.h>
20 #include <d3dx9.h>
21 #include <windows.h>
22 #include <stdio.h>
23 
24 #ifndef _PI
25 #define _PI ((FLOAT)3.141592654f)
26 #endif
27 
28 #ifndef DEGTORAD
29 #define DEGTORAD(degree) ((PI / 180.0f) * (degree))
30 #endif
31 
32 #ifndef DEGTORAD
33 #define RADTODEG(radian) ((180.0f / PI) * (radian))
34 #endif
35 
36 #define MenuGroupOptions "MENUGROUP_OPTIONS"
37 #define MenuItemOptions "MENUITEM_OPTIONS"
38 #define MenuHotkeys "MENU_HOTKEYS"
39 
40 #ifndef CLTFX_H
41 #define CLTFX_H
42 
43 typedef enum menu_colors_s
44 {
54 
55 typedef enum menu_itemtypes_s
56 {
60 
61 struct pGroup
62 {
63  char title[20];
64  float value;
65  bool settings;
66  int max, min, GroupID;
67 };
68 
69 struct pItem
70 {
71  char title[20];
72  float* value;
73  int max, min, vKey, GroupID;
74  char desc[50][50];
76 };
77 
78 struct QuadVertex
79 {
80  float x, y, z, rhw;
81  DWORD dwColor;
82 };
83 
84 struct LineVertex
85 {
86  float x, y, z, rhw;
87  D3DCOLOR color;
88  float tu, tv;
89 };
90 
91 struct Mouse
92 {
93  bool m_bIsLeftSingleClicked, m_bIsRightClicked, m_bIsMiddleClicked, m_bIsLeftHeld, Drag, m_bIsMenuOpen;
94  int x, y;
95 };
96 
97 class cMenu
98 {
99 public:
100  cMenu(int MAX_MENU, int MAX_GROUP, int MAX_DRAW);
101  ~cMenu();
102 
103  //==========SetUp Functions ( Call InitializeMenu or nothing will work! )
104  void SetActiveMode(bool m_bMode);
105  void SetColor(int type, const D3DCOLOR color);
106  void SetInitialCoords(int x, int y);
107  //void SetSettingFile(char *SettingsFile);
108  void InitializeMenu(void);
109 
110  //==========D3D Font Stuff
111  void InitalizeFont(char *font, int size, IDirect3DDevice9* pD3Ddev);
112  void PostReset(char *font, int size, IDirect3DDevice9* pD3Ddev);
113  void PreReset(void);
114 
115  //==========Menu & Group -Items ( MenuItems cannot be added without a valid ItemGroup! )
116  int AddMenuGroup(const char title[20]);
117  int AddMenuItem(const char title[20], float *cvar, int min, int max, int GroupID, int vKey = NULL, char *Opt = NULL, ...);
118  int getItemsCount();
119 
120  //==========Help Functions
121  void DisableAllMenuItems();
122  bool IsMouseInVector(int x, int y, int w, int h);
123 
124  //==========Main MenuTree Draw Function
125  void DrawMenu(char* title, IDirect3DDevice9* pDevice);
126 
127  //==========Navigation & Control
128  void HandleItemHotkeys(WPARAM wKey);
129  void HandleKeyNavigation(WPARAM wKey);
130  //void HandleMouseNavigation(WPARAM wKey);
131  void DragMenuWindow(void);
132  void HandleKeys(WPARAM wParams, LPARAM lParams, UINT msg);
133 
134  //==========Drawing Stuff
135  //int GetTextWidth(char* text);
136  void DrawText1(int x, int y, DWORD color, char *szFormat, ...);
137  void DrawGameTextPixel(int x, int y, DWORD color, char *szFormat, ...);
138  void FillRGB(int x, int y, int w, int h, D3DCOLOR color, IDirect3DDevice9* pDevice);
139  void FillARGB(int x, int y, int w, int h, D3DCOLOR color, IDirect3DDevice9* pDevice);//removed, redirected to FillRGB()
140  void FillARGBGradient(int x, int y, int w, int h, D3DCOLOR color1, DWORD color2, IDirect3DDevice9* pDevice);//removed.
141  void DrawBorder(int x, int y, int w, int h, int px, D3DCOLOR BorderColor, IDirect3DDevice9* pDevice);
142  void DrawBox(int x, int y, int w, int h, D3DCOLOR BoxColor, D3DCOLOR BorderColor, IDirect3DDevice9* pDevice);
143  void DrawHealthBox(int x, int y, DWORD m_dColorOut, DWORD m_dColorIn, int m_iHealth, int m_iMaxHealth, IDirect3DDevice9* pDevice);
144  void DrawMouse(IDirect3DDevice9* pDevice, bool DrawIt = false);//removed.
145  void DrawRadar(int x, int y, int size, IDirect3DDevice9* pDevice);
146  void DrawDot(int x, int y, int r, int g, int b, IDirect3DDevice9* pDevice);
147  void DrawLine(int x1, int y1, int x2, int y2, D3DCOLOR col, IDirect3DDevice9* pDevice);
148  void DrawCircle(int x, int y, float radius, D3DCOLOR color, IDirect3DDevice9* pDevice);;
149 
150  bool bMenu, FontCreated, firstInit, moving[3];
152 private:
153  //==========Private Help Functions
154  int GetMaxItemsToDraw(void);
155  int GetMaxItemsInGroup(int index);
156  int GetRealIterator(int Item, int &Type);
157  LineVertex CreateD3DTLVERTEX(float X, float Y, float Z, float RHW, D3DCOLOR color, float U, float V);
158 
159  ID3DXFont* menuFont;
160  pItem* menuItem;
161  pGroup* menuGroup;
162  POINT menuPos;
163  int MAX_ITEMS, MAX_GROUPS, curItem;
164  bool bInitialized, bCanUseSettings;
165  D3DCOLOR MenuColors[10];
166  int height;
167  int itemOffset;
168  int MaxItemsToDrawAtOnce;
169  //char szSettingsFile[256];
170 };
171 
172 #endif
173 
174 extern cMenu menu;
Definition: cLTFX.h:57
enum menu_itemtypes_s menu_itemtypes_t
float z
Definition: cLTFX.h:80
Definition: cLTFX.h:91
menu_itemtypes_s
Definition: cLTFX.h:55
Definition: cLTFX.h:78
Mouse m_mouse
Definition: cLTFX.h:151
char title[20]
Definition: cLTFX.h:63
Definition: cLTFX.h:97
int max
Definition: cLTFX.h:66
int y
Definition: cLTFX.h:94
Definition: cLTFX.h:84
const int MAX_GROUP
Definition: d3d9dev.cpp:78
Definition: cLTFX.h:52
float * value
Definition: cLTFX.h:72
float value
Definition: cLTFX.h:64
menu_colors_s
Definition: cLTFX.h:43
cMenu menu
Definition: d3d9dev.cpp:80
int vKey
Definition: cLTFX.h:73
Definition: cLTFX.h:69
bool useDesc
Definition: cLTFX.h:75
D3DCOLOR color
Definition: cLTFX.h:87
Definition: cLTFX.h:47
Definition: cLTFX.h:46
int min
Definition: cLTFX.h:66
float z
Definition: cLTFX.h:86
const int MAX_DRAW
Definition: d3d9dev.cpp:79
bool settings
Definition: cLTFX.h:65
Definition: cLTFX.h:50
Definition: cLTFX.h:49
enum menu_colors_s menu_colors_t
DWORD dwColor
Definition: cLTFX.h:81
Definition: cLTFX.h:58
Definition: cLTFX.h:45
float tv
Definition: cLTFX.h:88
Definition: cLTFX.h:48
Definition: cLTFX.h:51
int GroupID
Definition: cLTFX.h:66
bool m_bIsRightClicked
Definition: cLTFX.h:93
Definition: cLTFX.h:61