mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-14 16:40:52 +00:00
- Exhumed: Initial setup of new statusbar sequence exports, starting with DrawStatusSequence()
.
This commit is contained in:
parent
95e84ba1f8
commit
7ca73aa562
6 changed files with 105 additions and 75 deletions
|
@ -327,9 +327,10 @@ public:
|
|||
}
|
||||
|
||||
// returns address of first element
|
||||
T *Data() const
|
||||
T *Data(size_t index = 0) const
|
||||
{
|
||||
return &Array[0];
|
||||
assert(index <= Count);
|
||||
return &Array[index];
|
||||
}
|
||||
|
||||
unsigned IndexOf(const T& elem) const
|
||||
|
|
|
@ -435,6 +435,7 @@ int addSeq(const char *seqName)
|
|||
(int16_t)(nSeqFrameChunkPosX[nChunk] - CenterX),
|
||||
(int16_t)(nSeqFrameChunkPosY[nChunk] - CenterY),
|
||||
nSeqFrameChunkPicnum[nChunk],
|
||||
tileGetTexture(nSeqFrameChunkPicnum[nChunk])->GetID(),
|
||||
nSeqFrameChunkFlags[nChunk],
|
||||
});
|
||||
}
|
||||
|
@ -870,6 +871,68 @@ void seq_PlotSequence(const int nSprite, const FName seqFile, const int16_t seqI
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
DEFINE_FIELD_X(SeqFrameChunk, SeqFrameChunk, xpos);
|
||||
DEFINE_FIELD_X(SeqFrameChunk, SeqFrameChunk, ypos);
|
||||
DEFINE_FIELD_X(SeqFrameChunk, SeqFrameChunk, tex);
|
||||
DEFINE_FIELD_X(SeqFrameChunk, SeqFrameChunk, flags);
|
||||
|
||||
DEFINE_FIELD_X(SeqFrame, SeqFrame, sound);
|
||||
DEFINE_FIELD_X(SeqFrame, SeqFrame, flags);
|
||||
|
||||
DEFINE_FIELD_X(Seq, Seq, flags);
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_SeqFrame, playSound)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(SeqFrame);
|
||||
self->playSound(PlayerList[nLocalPlayer].pActor);
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_SeqFrame, Size)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(SeqFrame);
|
||||
ACTION_RETURN_INT(self->chunks.Size());
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_SeqFrame, getChunk)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(SeqFrame);
|
||||
PARAM_INT(chunkId);
|
||||
ACTION_RETURN_POINTER(self->chunks.Data(chunkId));
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Seq, Size)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(Seq);
|
||||
ACTION_RETURN_INT(self->frames.Size());
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Seq, getFrame)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(Seq);
|
||||
PARAM_INT(frameId);
|
||||
ACTION_RETURN_POINTER(self->frames.Data(frameId));
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Exhumed, GetStatusSequence)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_INT(seqId);
|
||||
ACTION_RETURN_POINTER(getFileSeqs("status")->Data(seqId));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void SerializeSequence(FSerializer& arc)
|
||||
{
|
||||
if (arc.BeginObject("sequence"))
|
||||
|
|
|
@ -113,6 +113,7 @@ struct SeqFrameChunk
|
|||
int16_t xpos;
|
||||
int16_t ypos;
|
||||
int16_t picnum;
|
||||
FTextureID tex; // FIXME (native wants picnum, statusbar wants texid)
|
||||
int16_t flags;
|
||||
};
|
||||
|
||||
|
|
|
@ -50,59 +50,12 @@ void InitStatus()
|
|||
nStatusSeqOffset = getSeqFromId(kSeqStatus);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// This is to hide the dirt from the script code.
|
||||
// These sequence arrays later need to be refactored
|
||||
// if this is ever supposed to become a useful feature,
|
||||
// so hide the dirty internals behind a handful of functions.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
struct ChunkFrame
|
||||
{
|
||||
FTextureID tex;
|
||||
int x, y;
|
||||
int flags;
|
||||
|
||||
void GetChunkFrame(int nFrameBase)
|
||||
{
|
||||
x = getSeqFrameChunkPosX(nFrameBase);
|
||||
y = getSeqFrameChunkPosY(nFrameBase);
|
||||
auto ttex = tileGetTexture(getSeqFrameChunkPicnum(nFrameBase));
|
||||
if (ttex) tex = ttex->GetID();
|
||||
else tex.SetInvalid();
|
||||
flags = getSeqFrameChunkFlags(nFrameBase);
|
||||
}
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_ChunkFrame, GetChunkFrame)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(ChunkFrame);
|
||||
PARAM_INT(index);
|
||||
self->GetChunkFrame(index);
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Exhumed, GetStatusSequence)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_INT(nSequence);
|
||||
PARAM_INT(frameindex);
|
||||
|
||||
frameindex += getSeqFrame(nSequence + nStatusSeqOffset);
|
||||
if (numret > 0) ret[0].SetInt(getSeqFrameChunk(frameindex));
|
||||
if (numret > 1) ret[1].SetInt(getSeqFrameChunkCount(frameindex));
|
||||
return min(numret, 2);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Exhumed, MoveStatusSequence)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
|
|
|
@ -7,7 +7,7 @@ struct Exhumed native
|
|||
native static bool LocalSoundPlaying();
|
||||
native static void playCDTrack(int track, bool looped);
|
||||
native static void DrawPlasma();
|
||||
native static int, int GetStatusSequence(int seq, int index);
|
||||
native static Seq GetStatusSequence(int seqId);
|
||||
native static int MoveStatusSequence(int s1, int s2);
|
||||
native static int SizeOfStatusSequence(int s1);
|
||||
native static ExhumedPlayer GetViewPlayer();
|
||||
|
@ -32,6 +32,32 @@ struct Exhumed native
|
|||
}
|
||||
}
|
||||
|
||||
struct SeqFrameChunk native
|
||||
{
|
||||
native int16 xpos;
|
||||
native int16 ypos;
|
||||
native TextureID tex;
|
||||
native int16 flags;
|
||||
}
|
||||
|
||||
struct SeqFrame native
|
||||
{
|
||||
native int16 sound;
|
||||
native int16 flags;
|
||||
|
||||
native uint Size();
|
||||
native SeqFrameChunk getChunk(int chunkId);
|
||||
native void playSound();
|
||||
}
|
||||
|
||||
struct Seq native
|
||||
{
|
||||
native int16 flags;
|
||||
|
||||
native uint Size();
|
||||
native SeqFrame getFrame(int frameId);
|
||||
}
|
||||
|
||||
struct ExhumedPlayer native
|
||||
{
|
||||
native int16 nHealth;
|
||||
|
|
|
@ -19,15 +19,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
struct ChunkFrame // this wraps the internal (mis-)representation of the chunk data.
|
||||
{
|
||||
TextureID tex;
|
||||
int x, y;
|
||||
int flags;
|
||||
|
||||
native void GetChunkFrame(int nFrameBase);
|
||||
}
|
||||
|
||||
class ExhumedStatusBar : RazeStatusBar
|
||||
{
|
||||
HUDFont textfont, numberFont;
|
||||
|
@ -99,17 +90,15 @@ class ExhumedStatusBar : RazeStatusBar
|
|||
|
||||
void DrawStatusSequence(int nSequence, int frameindex, double yoffset, double xoffset = 0, bool trueadjust = false)
|
||||
{
|
||||
int nFrameBase, nFrameSize;
|
||||
[nFrameBase, nFrameSize] = Exhumed.GetStatusSequence(nSequence, frameindex);
|
||||
let seqFrame = Exhumed.GetStatusSequence(nSequence).getFrame(frameindex);
|
||||
|
||||
for(; nFrameSize > 0; nFrameSize--, nFrameBase++)
|
||||
for (uint i = 0; i < seqFrame.Size(); i++)
|
||||
{
|
||||
let frameChunk = seqFrame.getChunk(i);
|
||||
int flags = 0;
|
||||
ChunkFrame chunk;
|
||||
chunk.GetChunkFrame(nFrameBase);
|
||||
|
||||
double x = chunk.x + xoffset;
|
||||
double y = chunk.y + yoffset;
|
||||
double x = frameChunk.xpos + xoffset;
|
||||
double y = frameChunk.ypos + yoffset;
|
||||
|
||||
if (hud_size <= Hud_StbarOverlay)
|
||||
{
|
||||
|
@ -131,14 +120,14 @@ class ExhumedStatusBar : RazeStatusBar
|
|||
y -= 100;
|
||||
}
|
||||
|
||||
if (chunk.flags & 3)
|
||||
if (frameChunk.flags & 3)
|
||||
{
|
||||
// This is hard to align with bad offsets, so skip that treatment for mirrored elements.
|
||||
flags |= DI_ITEM_RELCENTER;
|
||||
}
|
||||
else
|
||||
{
|
||||
let tsiz = TexMan.GetScaledSize(chunk.tex);
|
||||
let tsiz = TexMan.GetScaledSize(frameChunk.tex);
|
||||
if (trueadjust)
|
||||
{
|
||||
x -= tsiz.x * 0.5;
|
||||
|
@ -152,12 +141,12 @@ class ExhumedStatusBar : RazeStatusBar
|
|||
flags |= DI_ITEM_OFFSETS;
|
||||
}
|
||||
|
||||
if (chunk.flags & 1)
|
||||
if (frameChunk.flags & 1)
|
||||
flags |= DI_MIRROR;
|
||||
if (chunk.flags & 2)
|
||||
if (frameChunk.flags & 2)
|
||||
flags |= DI_MIRRORY;
|
||||
|
||||
DrawTexture(chunk.tex, (x, y), flags);
|
||||
DrawTexture(frameChunk.tex, (x, y), flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,10 +158,7 @@ class ExhumedStatusBar : RazeStatusBar
|
|||
|
||||
TextureID GetStatusSequencePic(int nSequence, int frameindex)
|
||||
{
|
||||
int nFrameBase = Exhumed.GetStatusSequence(nSequence, frameindex);
|
||||
ChunkFrame chunk;
|
||||
chunk.GetChunkFrame(nFrameBase);
|
||||
return chunk.tex;
|
||||
return Exhumed.GetStatusSequence(nSequence).getFrame(frameindex).getChunk(0).tex;
|
||||
}
|
||||
|
||||
String GetStatusSequenceName(int nSequence, int frameindex)
|
||||
|
|
Loading…
Reference in a new issue