mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-13 00:24:12 +00:00
HUD interface leak fixes and enhancements. Something is still leaking
memory, though.
This commit is contained in:
parent
dedb2fa6bf
commit
dcf1bcf141
3 changed files with 62 additions and 18 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
@interface HUDObject : Object
|
@interface HUDObject : Object
|
||||||
{
|
{
|
||||||
Point origin;
|
Point origin, size;
|
||||||
BOOL visible;
|
BOOL visible;
|
||||||
integer handle;
|
integer handle;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,8 @@
|
||||||
- (Point) origin;
|
- (Point) origin;
|
||||||
- (void) setOrigin: (Point) newPoint;
|
- (void) setOrigin: (Point) newPoint;
|
||||||
- (void) translate: (Point) addPoint;
|
- (void) translate: (Point) addPoint;
|
||||||
|
- (Point) size;
|
||||||
|
//- (void) center Horizontal: (BOOL) h Vertical: (BOOL) v;
|
||||||
- (BOOL) isVisible;
|
- (BOOL) isVisible;
|
||||||
- (void) setVisible: (BOOL) _visible;
|
- (void) setVisible: (BOOL) _visible;
|
||||||
- (void) display;
|
- (void) display;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "draw.h"
|
#include "draw.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "gib.h"
|
#include "gib.h"
|
||||||
|
#include "string.h"
|
||||||
#include "HUD.h"
|
#include "HUD.h"
|
||||||
|
|
||||||
integer HUDHandleClass;
|
integer HUDHandleClass;
|
||||||
|
@ -13,6 +14,7 @@ integer HUDHandleClass;
|
||||||
|
|
||||||
- (id) initWithComponents: (integer) x : (integer) y
|
- (id) initWithComponents: (integer) x : (integer) y
|
||||||
{
|
{
|
||||||
|
self = [super init];
|
||||||
origin = [[Point alloc] initWithComponents: x :y];
|
origin = [[Point alloc] initWithComponents: x :y];
|
||||||
visible = YES;
|
visible = YES;
|
||||||
handle = GIB_Handle_New (self, HUDHandleClass);
|
handle = GIB_Handle_New (self, HUDHandleClass);
|
||||||
|
@ -23,6 +25,7 @@ integer HUDHandleClass;
|
||||||
- (void) free
|
- (void) free
|
||||||
{
|
{
|
||||||
[origin free];
|
[origin free];
|
||||||
|
[size free];
|
||||||
GIB_Handle_Free (handle, HUDHandleClass);
|
GIB_Handle_Free (handle, HUDHandleClass);
|
||||||
[super free];
|
[super free];
|
||||||
}
|
}
|
||||||
|
@ -37,6 +40,11 @@ integer HUDHandleClass;
|
||||||
return origin;
|
return origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (Point) size
|
||||||
|
{
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
- (void) setOrigin: (Point) newPoint
|
- (void) setOrigin: (Point) newPoint
|
||||||
{
|
{
|
||||||
[origin setPoint :newPoint];
|
[origin setPoint :newPoint];
|
||||||
|
@ -47,6 +55,16 @@ integer HUDHandleClass;
|
||||||
[origin addPoint :addPoint];
|
[origin addPoint :addPoint];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
- (void) center Horizontal: (BOOL) h Vertical: (BOOL) v
|
||||||
|
{
|
||||||
|
Point newCoords;
|
||||||
|
integer newX, newY;
|
||||||
|
|
||||||
|
if (h) {
|
||||||
|
newX = X
|
||||||
|
*/
|
||||||
|
|
||||||
- (BOOL) isVisible
|
- (BOOL) isVisible
|
||||||
{
|
{
|
||||||
return visible;
|
return visible;
|
||||||
|
@ -66,7 +84,7 @@ integer HUDHandleClass;
|
||||||
- (id) initWithComponents: (integer) x :(integer) y :(string) _text
|
- (id) initWithComponents: (integer) x :(integer) y :(string) _text
|
||||||
{
|
{
|
||||||
self = [super initWithComponents :x :y];
|
self = [super initWithComponents :x :y];
|
||||||
text = _text;
|
[self setText :_text];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -79,6 +97,8 @@ integer HUDHandleClass;
|
||||||
- (void) setText: (string) _text
|
- (void) setText: (string) _text
|
||||||
{
|
{
|
||||||
text = _text;
|
text = _text;
|
||||||
|
[size free];
|
||||||
|
size = [[Point alloc] initWithComponents :8*(integer) strlen (text) :8];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) display
|
- (void) display
|
||||||
|
@ -92,21 +112,23 @@ integer HUDHandleClass;
|
||||||
- (id) initWithComponents: (integer)x :(integer)y :(string) _file
|
- (id) initWithComponents: (integer)x :(integer)y :(string) _file
|
||||||
{
|
{
|
||||||
self = [super initWithComponents :x :y];
|
self = [super initWithComponents :x :y];
|
||||||
picture = [[QPic alloc] initName :_file];
|
[self setFile :_file];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) free
|
- (void) free
|
||||||
{
|
{
|
||||||
[super free];
|
|
||||||
[picture free];
|
[picture free];
|
||||||
|
[super free];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setFile: (string) _file
|
- (void) setFile: (string) _file
|
||||||
{
|
{
|
||||||
[picture free];
|
[picture free];
|
||||||
picture = [[QPic alloc] initName :_file];
|
picture = [[QPic alloc] initName :_file];
|
||||||
|
[size free];
|
||||||
|
size = [[Point alloc] initWithComponents :[picture width] :[picture height]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) display
|
- (void) display
|
||||||
|
|
|
@ -15,8 +15,8 @@ void (integer argc, string [] argv) gib_hud_new_text_f =
|
||||||
return;
|
return;
|
||||||
|
|
||||||
newText = [[HUDText alloc] initWithComponents
|
newText = [[HUDText alloc] initWithComponents
|
||||||
:(integer) stof (argv[1])
|
:stoi (argv[1])
|
||||||
:(integer) stof (argv[2])
|
:stoi (argv[2])
|
||||||
:argv[3]
|
:argv[3]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -33,8 +33,8 @@ void (integer argc, string [] argv) gib_hud_new_graphic_f =
|
||||||
return;
|
return;
|
||||||
|
|
||||||
newGraphic = [[HUDGraphic alloc] initWithComponents
|
newGraphic = [[HUDGraphic alloc] initWithComponents
|
||||||
:(integer) stof (argv[1])
|
:stoi (argv[1])
|
||||||
:(integer) stof (argv[2])
|
:stoi (argv[2])
|
||||||
:argv[3]
|
:argv[3]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -53,16 +53,36 @@ void (integer argc, string [] argv) gib_hud_delete_f =
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
trashObject = GIB_Handle_Get ((integer) stof (argv[i]), HUDHandleClass);
|
trashObject = GIB_Handle_Get (stoi (argv[i]), HUDHandleClass);
|
||||||
if (trashObject) {
|
if (trashObject) {
|
||||||
[HUDObjects removeItem :trashObject];
|
[HUDObjects removeItem :trashObject];
|
||||||
[trashObject free];
|
[trashObject free];
|
||||||
} else
|
} else
|
||||||
dprint (sprintf ("Warning: no HUD object associated with handle %i\n", (integer) stof (argv[i])));
|
dprint (sprintf ("Warning: no HUD object associated with handle %i\n", stoi (argv[i])));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void (integer argc, string [] argv) gib_hud_get_origin_f =
|
void (integer argc, string [] argv) gib_hud_get_rect_f =
|
||||||
|
{
|
||||||
|
local HUDObject myObject;
|
||||||
|
local Point myPoint;
|
||||||
|
|
||||||
|
if (argc != 2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
myObject = GIB_Handle_Get (stoi (argv[1]), HUDHandleClass);
|
||||||
|
if (!myObject)
|
||||||
|
return;
|
||||||
|
|
||||||
|
myPoint = [myObject origin];
|
||||||
|
GIB_Return (itos ([myPoint x]));
|
||||||
|
GIB_Return (itos ([myPoint y]));
|
||||||
|
myPoint = [myObject size];
|
||||||
|
GIB_Return (itos ([myPoint x]));
|
||||||
|
GIB_Return (itos ([myPoint y]));
|
||||||
|
};
|
||||||
|
|
||||||
|
void (integer argc, string [] argv) gib_hud_get_size_f =
|
||||||
{
|
{
|
||||||
local HUDObject myObject;
|
local HUDObject myObject;
|
||||||
local Point myOrigin;
|
local Point myOrigin;
|
||||||
|
@ -70,7 +90,7 @@ void (integer argc, string [] argv) gib_hud_get_origin_f =
|
||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
myObject = GIB_Handle_Get ((integer) stof (argv[1]), HUDHandleClass);
|
myObject = GIB_Handle_Get (stoi (argv[1]), HUDHandleClass);
|
||||||
if (!myObject)
|
if (!myObject)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -87,14 +107,14 @@ void (integer argc, string [] argv) gib_hud_set_translate_f =
|
||||||
if (argc < 4)
|
if (argc < 4)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
p = [[Point alloc] initWithComponents :(integer) stof (argv[argc-2]) :(integer) stof (argv[argc-1])];
|
p = [[Point alloc] initWithComponents :stoi (argv[argc-2]) :stoi (argv[argc-1])];
|
||||||
|
|
||||||
if (argv[0] == "HUD::translate")
|
if (argv[0] == "HUD::translate")
|
||||||
for (i = 1; i < argc - 2; i++)
|
for (i = 1; i < argc - 2; i++)
|
||||||
[(HUDObject) GIB_Handle_Get ((integer) stof (argv[i]), HUDHandleClass) translate :p];
|
[(HUDObject) GIB_Handle_Get (stoi (argv[i]), HUDHandleClass) translate :p];
|
||||||
else
|
else
|
||||||
for (i = 1; i < argc - 2; i++)
|
for (i = 1; i < argc - 2; i++)
|
||||||
[(HUDObject) GIB_Handle_Get ((integer) stof (argv[i]), HUDHandleClass) setOrigin :p];
|
[(HUDObject) GIB_Handle_Get (stoi (argv[i]), HUDHandleClass) setOrigin :p];
|
||||||
[p free];
|
[p free];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -105,7 +125,7 @@ void (integer argc, string [] argv) gib_hud_set_text_f =
|
||||||
if (argc != 3)
|
if (argc != 3)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
myObject = GIB_Handle_Get ((integer) stof (argv[1]), HUDHandleClass);
|
myObject = GIB_Handle_Get (stoi (argv[1]), HUDHandleClass);
|
||||||
if (!myObject || ![myObject isKindOf :[HUDText class]])
|
if (!myObject || ![myObject isKindOf :[HUDText class]])
|
||||||
return;
|
return;
|
||||||
[myObject setText :argv[2]];
|
[myObject setText :argv[2]];
|
||||||
|
@ -118,7 +138,7 @@ void (integer argc, string [] argv) gib_hud_set_file_f =
|
||||||
if (argc != 3)
|
if (argc != 3)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
myObject = GIB_Handle_Get ((integer) stof (argv[1]), HUDHandleClass);
|
myObject = GIB_Handle_Get (stoi (argv[1]), HUDHandleClass);
|
||||||
if (!myObject || ![myObject isKindOf :[HUDGraphic class]])
|
if (!myObject || ![myObject isKindOf :[HUDGraphic class]])
|
||||||
return;
|
return;
|
||||||
[myObject setFile :argv[2]];
|
[myObject setFile :argv[2]];
|
||||||
|
@ -129,7 +149,7 @@ void () HUD_Init =
|
||||||
GIB_Builtin_Add ("HUD::newText", gib_hud_new_text_f);
|
GIB_Builtin_Add ("HUD::newText", gib_hud_new_text_f);
|
||||||
GIB_Builtin_Add ("HUD::newGraphic", gib_hud_new_graphic_f);
|
GIB_Builtin_Add ("HUD::newGraphic", gib_hud_new_graphic_f);
|
||||||
GIB_Builtin_Add ("HUD::delete", gib_hud_delete_f);
|
GIB_Builtin_Add ("HUD::delete", gib_hud_delete_f);
|
||||||
GIB_Builtin_Add ("HUD::getOrigin", gib_hud_get_origin_f);
|
GIB_Builtin_Add ("HUD::getRect", gib_hud_get_rect_f);
|
||||||
GIB_Builtin_Add ("HUD::setOrigin", gib_hud_set_translate_f);
|
GIB_Builtin_Add ("HUD::setOrigin", gib_hud_set_translate_f);
|
||||||
GIB_Builtin_Add ("HUD::translate", gib_hud_set_translate_f);
|
GIB_Builtin_Add ("HUD::translate", gib_hud_set_translate_f);
|
||||||
GIB_Builtin_Add ("HUD::setText", gib_hud_set_text_f);
|
GIB_Builtin_Add ("HUD::setText", gib_hud_set_text_f);
|
||||||
|
|
Loading…
Reference in a new issue