AmendHub

Download:

cyberslak

/

lightsout

/

amendments

/

10

entity_ldef: add

Custom entity LDEF which simply shows the name of an entity.

cyberslak made amendment 10 25 days ago
--- entity_ldef.c Sun Mar 9 21:13:03 2025 +++ entity_ldef.c Sun Mar 9 21:13:03 2025 @@ -0,0 +1,44 @@ +#include <string.h> +#include "entity_ldef.h" +#include "entity.h" +#include "util.h" + +pascal short +entity_ldef_proc(short message, Boolean selected, Rect *cellRect, + Cell theCell, short dataOffset, short dataLen, + ListHandle theList) +{ + FontInfo info; + Handle cells = (**theList).cells; + struct entity* ent; + HLock(cells); + + GetFontInfo(&info); + + switch (message) + { + case lInitMsg: + break; + case lCloseMsg: + break; + case lDrawMsg: + if (dataLen > 0) + { + if (dataLen != sizeof(Ptr)) die("invalid dataLen %d", dataLen); + memcpy(&ent, (*cells) + dataOffset, dataLen); + EraseRect(cellRect); + MoveTo(cellRect->left + 2, cellRect->top + info.ascent); + DrawText(ent->state.name, 0, strlen(ent->state.name)); + } + if (selected) + { + InvertRect(cellRect); + } + break; + case lHiliteMsg: + InvertRect(cellRect); + break; + } + + HUnlock(cells); +} --- entity_ldef.h Sun Mar 9 20:34:47 2025 +++ entity_ldef.h Sun Mar 9 20:34:47 2025 @@ -0,0 +1,6 @@ +#pragma once + +pascal short +entity_ldef_proc(short message, Boolean selected, Rect *cellRect, + Cell theCell, short dataOffset, + short dataLen, ListHandle theList);