- some conceptual work on statusbar stuff. This looks like a viable approach to build something that can replace SBARINFO.

This commit is contained in:
Christoph Oelckers 2017-03-22 19:56:21 +01:00
parent f0e4f54c80
commit 9bd75bcac5
4 changed files with 70 additions and 0 deletions

View file

@ -1429,3 +1429,65 @@ DBaseStatusBar *CreateStrifeStatusBar()
}
return sb;
}
static DObject *InitObject(PClass *type, int paramnum, VM_ARGS)
{
auto obj = type->CreateNew();
// Todo: init
return obj;
}
DEFINE_ACTION_FUNCTION(DStatusbarWidget, AppendWidget)
{
PARAM_SELF_PROLOGUE(DObject);
PARAM_CLASS(type, DObject);
if (!type->IsDescendantOf(NAME_StatusbarWidget) || type->IsDescendantOf(NAME_StatusbarCondition))
{
ThrowAbortException(X_OTHER, "Invalid class %s for AppendWidget", type->TypeName.GetChars());
}
auto obj = InitObject(type, paramnum, VM_ARGS_NAMES);
auto owner = self->PointerVar<DObject>(NAME_Owner);
self->PointerVar<DObject>(NAME_Next) = obj;
obj->PointerVar<DObject>(NAME_Prev) = self;
obj->PointerVar<DObject>(NAME_Owner) = owner;
ACTION_RETURN_POINTER(obj);
}
DEFINE_ACTION_FUNCTION(DStatusbarWidget, BeginCondition)
{
PARAM_SELF_PROLOGUE(DObject);
PARAM_CLASS(type, DObject);
if (!type->IsDescendantOf(NAME_StatusbarCondition))
{
ThrowAbortException(X_OTHER, "Invalid class %s for BeginCondition", type->TypeName.GetChars());
}
auto obj = InitObject(type, paramnum, VM_ARGS_NAMES);
auto head = PClass::FindClass(NAME_StatusbarWidget)->CreateNew();
head->PointerVar<DObject>(NAME_Owner) = self;
self->PointerVar<DObject>(NAME_Children) = head;
ACTION_RETURN_POINTER(head);
}
DEFINE_ACTION_FUNCTION(DStatusbarWidget, EndCondition)
{
PARAM_SELF_PROLOGUE(DObject);
auto owner = self->PointerVar<DObject>(NAME_Owner);
if (owner == nullptr || !owner->IsKindOf(NAME_StatusbarCondition))
{
ThrowAbortException(X_OTHER, "No matching BeginCondition found for EndCondition");
}
ACTION_RETURN_POINTER(owner);
}
DEFINE_ACTION_FUNCTION(DStatusbarWidget, Finish)
{
PARAM_SELF_PROLOGUE(DObject);
auto owner = self->PointerVar<DObject>(NAME_Owner);
if (owner == nullptr || owner->PointerVar<DObject>(NAME_Owner) != owner || owner->GetClass()->TypeName != NAME_StatusbarWidget)
{
ThrowAbortException(X_OTHER, "No matching Begin found for Finish");
}
ACTION_RETURN_POINTER(owner);
}

View file

@ -648,6 +648,12 @@ xx(Staticconst)
xx(DeathmatchStatusScreen)
xx(CoopStatusScreen)
xx(RavenStatusScreen)
xx(StatusbarWidget)
xx(StatusbarCondition)
xx(Next)
xx(Prev)
xx(Children)
xx(Owner)
// USDF keywords
xx(Amount)

View file

@ -914,6 +914,7 @@ void NullParam(const char *varname);
#define PARAM_POINTERTYPE(x,type) ++paramnum; PARAM_POINTERTYPE_AT(paramnum,x,type)
#define PARAM_OBJECT(x,type) ++paramnum; PARAM_OBJECT_AT(paramnum,x,type)
#define PARAM_CLASS(x,base) ++paramnum; PARAM_CLASS_AT(paramnum,x,base)
#define PARAM_CLASS(x,base) ++paramnum; PARAM_CLASS_AT(paramnum,x,base)
#define PARAM_POINTER_NOT_NULL(x,type) ++paramnum; PARAM_POINTER_NOT_NULL_AT(paramnum,x,type)
#define PARAM_OBJECT_NOT_NULL(x,type) ++paramnum; PARAM_OBJECT_NOT_NULL_AT(paramnum,x,type)
#define PARAM_CLASS_NOT_NULL(x,base) ++paramnum; PARAM_CLASS_NOT_NULL_AT(paramnum,x,base)

View file

@ -35,6 +35,7 @@ version "2.5"
#include "zscript/statusbar/statusbar.txt"
#include "zscript/statusbar/strife_sbar.txt"
#include "zscript/statusbar/sbarinfowrapper.txt"
#include "zscript/statusbar/statusbarwidget.txt"
#include "zscript/inventory/inventory.txt"
#include "zscript/inventory/inv_misc.txt"