Skip to content

Commit

Permalink
feat: more 'subscreenwidget' datatype implementation for type vars
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilyV99 committed Sep 9, 2023
1 parent 9a83342 commit 5c0c1a9
Show file tree
Hide file tree
Showing 12 changed files with 739 additions and 29 deletions.
84 changes: 68 additions & 16 deletions resources/docs/ZScript_Additions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8934,31 +8934,37 @@ int PageTransArgs[];
// some widget types, as listed.
//

int Tile;
* The widget's main tile.
* For SUBWIDG_MINITILE, can use the 'SUB_SPTILE_' constant values.
* VALID WIDGETS:
* SUBWIDG_FRAME, SUBWIDG_MCGUFF, SUBWIDG_TILEBLOCK, SUBWIDG_MINITILE

int CSet;
* The object's main cset. Normal csets, as well as the 'SUB_CS_' constants,
* The widget's main cset. Normal csets, as well as the 'SUB_CS_' constants,
* can be used for its' value.
* VALID WIDGETS:
* SUBWIDG_FRAME,
* SUBWIDG_FRAME, SUBWIDG_MCGUFF, SUBWIDG_TILEBLOCK, SUBWIDG_MINITILE

int Tile;
* The object's main tile.
int Flip;
* The widget's flip value.
* VALID WIDGETS:
* SUBWIDG_FRAME
* SUBWIDG_MCGUFF, SUBWIDG_TILEBLOCK, SUBWIDG_MINITILE

int Font;
* The object's Font, use the 'FONT_' constants.
* The widget's Font, use the 'FONT_' constants.
* VALID WIDGETS:
* SUBWIDG_TEXT, SUBWIDG_TIME, SUBWIDG_COUNTER, SUBWIDG_OLDCTR,
* SUBWIDG_BTNCOUNTER, SUBWIDG_MMAPTITLE

int Align;
* The object's Alignment, use the 'TF_' constants.
* The widget's Alignment, use the 'TF_' constants.
* VALID WIDGETS:
* SUBWIDG_TEXT, SUBWIDG_TIME, SUBWIDG_COUNTER, SUBWIDG_BTNCOUNTER,
* SUBWIDG_MMAPTITLE

int ShadowType;
* The object's Shadow Type, use the 'SHD_' constants.
* The widget's Shadow Type, use the 'SHD_' constants.
* VALID WIDGETS:
* SUBWIDG_TEXT, SUBWIDG_TIME, SUBWIDG_COUNTER, SUBWIDG_OLDCTR,
* SUBWIDG_BTNCOUNTER, SUBWIDG_MMAPTITLE
Expand All @@ -8972,33 +8978,53 @@ void SetText(char32[] str);
* SUBWIDG_TEXT

int ColorText;
* The object's color index used for Text
* The widget's color index used for Text
* VALID WIDGETS:
* SUBWIDG_TEXT, SUBWIDG_TIME, SUBWIDG_COUNTER, SUBWIDG_OLDCTR,
* SUBWIDG_BTNCOUNTER, SUBWIDG_MMAPTITLE
* SUBWIDG_BTNCOUNTER, SUBWIDG_MMAPTITLE, SUBWIDG_MCGUFF_FRAME

int ColorShadow;
* The object's color index used for Shadows
* The widget's color index used for Shadows
* VALID WIDGETS:
* SUBWIDG_TEXT, SUBWIDG_TIME, SUBWIDG_COUNTER, SUBWIDG_OLDCTR,
* SUBWIDG_BTNCOUNTER, SUBWIDG_MMAPTITLE

int ColorBG;
* The object's color index used for background
* The widget's color index used for background
* VALID WIDGETS:
* SUBWIDG_TEXT, SUBWIDG_TIME, SUBWIDG_COUNTER, SUBWIDG_OLDCTR,
* SUBWIDG_BTNCOUNTER, SUBWIDG_MMAPTITLE
* SUBWIDG_BTNCOUNTER, SUBWIDG_MMAPTITLE, SUBWIDG_BGCOLOR

int ColorOutline;
* The object's color index used for outline
* The widget's color index used for outline
* VALID WIDGETS:
* SUBWIDG_LINE, SUBWIDG_RECT
* SUBWIDG_LINE, SUBWIDG_RECT, SUBWIDG_MCGUFF_FRAME

int ColorFill;
* The object's color index used for fill
* The widget's color index used for fill
* VALID WIDGETS:
* SUBWIDG_RECT

int ColorPlayer;
* The widget's color index used to indicate the player
* VALID WIDGETS:
* SUBWIDG_MMAP, SUBWIDG_LMAP

int ColorCompassBlink;
* The widget's color index used to indicate the blinking compass
* VALID WIDGETS:
* SUBWIDG_MMAP

int ColorCompassOff;
* The widget's color index used to indicate the off compass
* VALID WIDGETS:
* SUBWIDG_MMAP

int ColorRoom;
* The widget's color index used to indicate rooms
* VALID WIDGETS:
* SUBWIDG_LMAP

int Button;
* The item button associated with the widget.
* Use the 'ITMBTN_' constants for this value.
Expand Down Expand Up @@ -9036,7 +9062,33 @@ int CostIndex;
* VALID WIDGETS:
* SUBWIDG_BTNCOUNTER

int ItemClass;
* The itemclass used by the widget (0 <= ItemClass < IC_MAXUSABLE)
* VALID WIDGETS:
* SUBWIDG_ITEMSLOT

int ItemID;
* The item ID used by the widget (-1 <= ItemID < NUM_ITEMDATA)
* VALID WIDGETS:
* SUBWIDG_ITEMSLOT

int FrameTile;
int PieceTile;
int FrameCSet;
int PieceCSet;
* The frame/piece tile/cset used by the widget.
* VALID WIDGETS:
* SUBWIDG_MCGUFF_FRAME

int Number;
* The number associated with the widget.
* VALID WIDGETS:
* SUBWIDG_MCGUFF

int Corner;
* The corner associated with the widget.
* VALID WIDGETS:
* SUBWIDG_MINITILE

////////////////////////////////////
////////////////////////////////////
Expand Down
6 changes: 5 additions & 1 deletion resources/include/std_zh/std_constants.zh
Original file line number Diff line number Diff line change
Expand Up @@ -4111,7 +4111,11 @@ enum //Special Subscreen Color Values
SUB_COLOR_MSGTXT = -33,
SUB_COLOR_MIN = -34
};

enum //Special Subscreen Tile Values
{
SUB_SPTILE_
SUB_SPTILE_MIN = -1
};
//{ Subscreen type-specific flag constants

enum // Flags for SUBWIDG_FRAME
Expand Down
2 changes: 1 addition & 1 deletion src/base/zdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -2440,7 +2440,7 @@ enum // used for gamedata ITEMS
*/



itype_maxusable,
itype_max=512
};

Expand Down
8 changes: 6 additions & 2 deletions src/dialog/subscr_props.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,7 @@ std::shared_ptr<GUI::Widget> SubscrPropDialog::view()
tswatches[0] = SelTileSwatch(
hAlign = 0.0,
tile = w->tile,
cset = w->cset,
cset = w->cs.get_cset(),
showvals = false,
// tilewid = local_subref->d7 ? 2 : 1,
// tilehei = local_subref->d7 ? 3 : 1,
Expand All @@ -1402,7 +1402,11 @@ std::shared_ptr<GUI::Widget> SubscrPropDialog::view()
onSelectFunc = [=](int32_t t, int32_t c, int32_t,int32_t)
{
w->tile = t;
w->cset = c;
if(w->cs.type != ssctMISC)
{
w->cs.type = c;
cs_sel[0]->setC1(c);
}
}
),
Column(padding = 0_px,
Expand Down
34 changes: 29 additions & 5 deletions src/new_subscr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3510,7 +3510,7 @@ bool SW_McGuffin::load_old(subscreen_object const& old)
return false;
SubscrWidget::load_old(old);
tile = old.d1;
cset = old.d2;
flip = old.d2;
number = old.d5;
SETFLAG(flags,SUBSCR_MCGUF_OVERLAY,old.d3);
SETFLAG(flags,SUBSCR_MCGUF_TRANSP,old.d4);
Expand All @@ -3532,7 +3532,7 @@ byte SW_McGuffin::getType() const
void SW_McGuffin::draw(BITMAP* dest, int32_t xofs, int32_t yofs, SubscrPage& page) const
{
puttriforce(dest,getX()+xofs,getY()+yofs,tile,cs.get_cset(),w,h,
cset,flags&SUBSCR_MCGUF_OVERLAY,flags&SUBSCR_MCGUF_TRANSP,number);
flip,flags&SUBSCR_MCGUF_OVERLAY,flags&SUBSCR_MCGUF_TRANSP,number);
}
SubscrWidget* SW_McGuffin::clone() const
{
Expand All @@ -3547,7 +3547,7 @@ bool SW_McGuffin::copy_prop(SubscrWidget const* src, bool all)
return false;
tile = other->tile;
number = other->number;
cset = other->cset;
flip = other->flip;
cs = other->cs;
return true;
}
Expand All @@ -3559,7 +3559,7 @@ int32_t SW_McGuffin::read(PACKFILE *f, word s_version)
return qe_invalid;
if(!p_igetl(&number,f))
return qe_invalid;
if(!p_getc(&cset,f))
if(!p_getc(&flip,f))
return qe_invalid;
if(auto ret = cs.read(f,s_version))
return ret;
Expand All @@ -3573,7 +3573,7 @@ int32_t SW_McGuffin::write(PACKFILE *f) const
new_return(1);
if(!p_iputl(number,f))
new_return(1);
if(!p_putc(cset,f))
if(!p_putc(flip,f))
new_return(1);
if(auto ret = cs.write(f))
return ret;
Expand Down Expand Up @@ -3708,6 +3708,30 @@ int32_t SW_MiniTile::get_tile() const
}
else return tile;
}
int32_t SW_MiniTile::get_int_tile() const
{
if(tile == -1)
{
if(special_tile >= ssmstMAX)
return 0;
return -(special_tile+1);
}
else return tile;
}
void SW_MiniTile::set_int_tile(int32_t val)
{
if(val < -ssmstMAX || val >= NEWMAXTILES) return;
if(val < 0)
{
tile = -1;
special_tile = -val-1;
}
else
{
tile = val;
special_tile = -1;
}
}
void SW_MiniTile::draw(BITMAP* dest, int32_t xofs, int32_t yofs, SubscrPage& page) const
{
auto t = (get_tile()<<2)+crn;
Expand Down
4 changes: 3 additions & 1 deletion src/new_subscr.h
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ struct SW_TriFrame : public SubscrWidget
struct SW_McGuffin : public SubscrWidget
{
int32_t tile, number;
byte cset;
byte flip;
SubscrColorInfo cs;

SW_McGuffin() = default;
Expand Down Expand Up @@ -832,6 +832,8 @@ struct SW_MiniTile : public SubscrWidget
SW_MiniTile(subscreen_object const& old);

int32_t get_tile() const;
int32_t get_int_tile() const;
void set_int_tile(int32_t val);
virtual bool load_old(subscreen_object const& old) override;
virtual word getW() const override; //Returns width in pixels
virtual word getH() const override; //Returns height in pixels
Expand Down
14 changes: 14 additions & 0 deletions src/parser/ByteCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2392,6 +2392,20 @@ string ZScript::VarToString(int32_t ID)
case SUBWIDGTY_INFCHAR: return "SUBWIDGTY_INFCHAR";
case SUBWIDGTY_COSTIND: return "SUBWIDGTY_COSTIND";

case SUBWIDGTY_COLOR_PLAYER: return "SUBWIDGTY_COLOR_PLAYER";
case SUBWIDGTY_COLOR_CMPBLNK: return "SUBWIDGTY_COLOR_CMPBLNK";
case SUBWIDGTY_COLOR_CMPOFF: return "SUBWIDGTY_COLOR_CMPOFF";
case SUBWIDGTY_COLOR_ROOM: return "SUBWIDGTY_COLOR_ROOM";
case SUBWIDGTY_ITEMCLASS: return "SUBWIDGTY_ITEMCLASS";
case SUBWIDGTY_ITEMID: return "SUBWIDGTY_ITEMID";
case SUBWIDGTY_FRAMETILE: return "SUBWIDGTY_FRAMETILE";
case SUBWIDGTY_FRAMECSET: return "SUBWIDGTY_FRAMECSET";
case SUBWIDGTY_PIECETILE: return "SUBWIDGTY_PIECETILE";
case SUBWIDGTY_PIECECSET: return "SUBWIDGTY_PIECECSET";
case SUBWIDGTY_FLIP: return "SUBWIDGTY_FLIP";
case SUBWIDGTY_NUMBER: return "SUBWIDGTY_NUMBER";
case SUBWIDGTY_CORNER: return "SUBWIDGTY_CORNER";

default:
{
sprintf(temp, "d%d", ID);
Expand Down
16 changes: 15 additions & 1 deletion src/parser/ByteCode.h
Original file line number Diff line number Diff line change
Expand Up @@ -1682,7 +1682,21 @@
#define SUBWIDGTY_INFCHAR 1589
#define SUBWIDGTY_COSTIND 1590

#define LAST_BYTECODE 1591
#define SUBWIDGTY_COLOR_PLAYER 1591
#define SUBWIDGTY_COLOR_CMPBLNK 1592
#define SUBWIDGTY_COLOR_CMPOFF 1593
#define SUBWIDGTY_COLOR_ROOM 1594
#define SUBWIDGTY_ITEMCLASS 1595
#define SUBWIDGTY_ITEMID 1596
#define SUBWIDGTY_FRAMETILE 1597
#define SUBWIDGTY_FRAMECSET 1598
#define SUBWIDGTY_PIECETILE 1599
#define SUBWIDGTY_PIECECSET 1600
#define SUBWIDGTY_FLIP 1601
#define SUBWIDGTY_NUMBER 1602
#define SUBWIDGTY_CORNER 1603

#define LAST_BYTECODE 1604

//} END OF BYTECODE

Expand Down
26 changes: 26 additions & 0 deletions src/parser/symbols/SubscreenDataSymbols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,32 @@ static AccessorTable SubscreenWidgetTable[] =
{ "setInfiniteChar", 0, ZTID_VOID, SUBWIDGTY_INFCHAR, 0, { ZTID_SUBSCREENWIDGET, ZTID_CHAR },{} },
{ "getCostIndex", 0, ZTID_FLOAT, SUBWIDGTY_COSTIND, 0, { ZTID_SUBSCREENWIDGET },{} },
{ "setCostIndex", 0, ZTID_VOID, SUBWIDGTY_COSTIND, 0, { ZTID_SUBSCREENWIDGET, ZTID_FLOAT },{} },
{ "getColorPlayer", 0, ZTID_FLOAT, SUBWIDGTY_COLOR_PLAYER, 0, { ZTID_SUBSCREENWIDGET },{} },
{ "setColorPlayer", 0, ZTID_VOID, SUBWIDGTY_COLOR_PLAYER, 0, { ZTID_SUBSCREENWIDGET, ZTID_FLOAT },{} },
{ "getColorCompassBlink", 0, ZTID_FLOAT, SUBWIDGTY_COLOR_CMPBLNK, 0, { ZTID_SUBSCREENWIDGET },{} },
{ "setColorCompassBlink", 0, ZTID_VOID, SUBWIDGTY_COLOR_CMPBLNK, 0, { ZTID_SUBSCREENWIDGET, ZTID_FLOAT },{} },
{ "getColorCompassOff", 0, ZTID_FLOAT, SUBWIDGTY_COLOR_CMPOFF, 0, { ZTID_SUBSCREENWIDGET },{} },
{ "setColorCompassOff", 0, ZTID_VOID, SUBWIDGTY_COLOR_CMPOFF, 0, { ZTID_SUBSCREENWIDGET, ZTID_FLOAT },{} },
{ "getColorRoom", 0, ZTID_FLOAT, SUBWIDGTY_COLOR_ROOM, 0, { ZTID_SUBSCREENWIDGET },{} },
{ "setColorRoom", 0, ZTID_VOID, SUBWIDGTY_COLOR_ROOM, 0, { ZTID_SUBSCREENWIDGET, ZTID_FLOAT },{} },
{ "getItemClass", 0, ZTID_FLOAT, SUBWIDGTY_ITEMCLASS, 0, { ZTID_SUBSCREENWIDGET },{} },
{ "setItemClass", 0, ZTID_VOID, SUBWIDGTY_ITEMCLASS, 0, { ZTID_SUBSCREENWIDGET, ZTID_FLOAT },{} },
{ "getItemID", 0, ZTID_FLOAT, SUBWIDGTY_ITEMID, 0, { ZTID_SUBSCREENWIDGET },{} },
{ "setItemID", 0, ZTID_VOID, SUBWIDGTY_ITEMID, 0, { ZTID_SUBSCREENWIDGET, ZTID_FLOAT },{} },
{ "getFrameTile", 0, ZTID_FLOAT, SUBWIDGTY_FRAMETILE, 0, { ZTID_SUBSCREENWIDGET },{} },
{ "setFrameTile", 0, ZTID_VOID, SUBWIDGTY_FRAMETILE, 0, { ZTID_SUBSCREENWIDGET, ZTID_FLOAT },{} },
{ "getFrameCSet", 0, ZTID_FLOAT, SUBWIDGTY_FRAMECSET, 0, { ZTID_SUBSCREENWIDGET },{} },
{ "setFrameCSet", 0, ZTID_VOID, SUBWIDGTY_FRAMECSET, 0, { ZTID_SUBSCREENWIDGET, ZTID_FLOAT },{} },
{ "getPieceTile", 0, ZTID_FLOAT, SUBWIDGTY_PIECETILE, 0, { ZTID_SUBSCREENWIDGET },{} },
{ "setPieceTile", 0, ZTID_VOID, SUBWIDGTY_PIECETILE, 0, { ZTID_SUBSCREENWIDGET, ZTID_FLOAT },{} },
{ "getPieceCSet", 0, ZTID_FLOAT, SUBWIDGTY_PIECECSET, 0, { ZTID_SUBSCREENWIDGET },{} },
{ "setPieceCSet", 0, ZTID_VOID, SUBWIDGTY_PIECECSET, 0, { ZTID_SUBSCREENWIDGET, ZTID_FLOAT },{} },
{ "getFlip", 0, ZTID_FLOAT, SUBWIDGTY_FLIP, 0, { ZTID_SUBSCREENWIDGET },{} },
{ "setFlip", 0, ZTID_VOID, SUBWIDGTY_FLIP, 0, { ZTID_SUBSCREENWIDGET, ZTID_FLOAT },{} },
{ "getNumber", 0, ZTID_FLOAT, SUBWIDGTY_NUMBER, 0, { ZTID_SUBSCREENWIDGET },{} },
{ "setNumber", 0, ZTID_VOID, SUBWIDGTY_NUMBER, 0, { ZTID_SUBSCREENWIDGET, ZTID_FLOAT },{} },
{ "getCorner", 0, ZTID_FLOAT, SUBWIDGTY_CORNER, 0, { ZTID_SUBSCREENWIDGET },{} },
{ "setCorner", 0, ZTID_VOID, SUBWIDGTY_CORNER, 0, { ZTID_SUBSCREENWIDGET, ZTID_FLOAT },{} },

{ "", 0, ZTID_VOID, -1, 0, {},{} }
};
Expand Down

0 comments on commit 5c0c1a9

Please sign in to comment.