Skip to content

Commit

Permalink
feat: 'subscreenwidget' datatype implementation for shared vars
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilyV99 committed Sep 9, 2023
1 parent 0d049c6 commit 5e8e6dc
Show file tree
Hide file tree
Showing 9 changed files with 1,507 additions and 373 deletions.
151 changes: 139 additions & 12 deletions resources/docs/ZScript_Additions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8776,24 +8776,13 @@ subscreenwidget Widgets[];
subscreendata SubData;
* Read-only. The subscreendata that owns this page.

//
// Only on ACTIVE subscreens:
//

int CursorPos;
* The position value of the selector.

subscreenwidget CreateWidget(int type);
* Adds a new widget of the specified type to the end of the page.
* Returns that widget, or NULL if fails.

void SwapWidgets(int index1, int index2);
* Swaps the widgets at the two indexes.

subscreenwidget FindWidget(int cursor_pos);
* Returns the widget designated by the specified cursor position,
* or NULL if it fails.

int SelectorMove(int cursor_pos, int dir, int flags)
* Returns the new cursor position found by moving in 'dir' from 'cursor_pos'.
* 'flags' determines:
Expand All @@ -8804,12 +8793,150 @@ void Delete();
* Deletes the page.
* If it is the last page, an empty page will be created in its' place.

//
// Only on ACTIVE subscreens:
//

int CursorPos;
* The position value of the selector.

subscreenwidget FindWidget(int cursor_pos);
* Returns the widget designated by the specified cursor position,
* or NULL if it fails.

///////////////////////
// subscreenwidget //
/////////////////////// subscreenwidget

int Type;
* Read-only. The widget's type, using 'SUBWIDG_' constants.

int Index;
* Read-only. The index of this widget within the page.

subscreenpage Page;
* Read-only. The page this widget is within.

bool VisibleFlags[];
* Flags related to the visibility of the widget.
* Use the 'SUBVISIB_' constants to access.

int X;
int Y;
* The X/Y position of the widget within the subscreen.
* Some types ignore these values.

int W;
int H;
* The width/height of the widget within the subscreen.
* This is USUALLY in pixels, but some types use different values!
* ex. for 2x2 frame, this is in minitiles, so 8 times less than pixels.
* Some types ignore these values altogether.

bool GenFlags[];
* The general flags for subscreen widgets.
* These are usually applicable regardless of widget type.
* Use the 'SUBW_GENFL_' constants to access.

bool Flags[];
* The type-specific flags for subscreen widgets.
* There is a different set of constants for this for each widget type.

//Selectable widget stuff
int Pos;
* The selector position of this flag.
* Only used if the widget is selectable (see 'GenFlags[]').

int Poses[4];
* The 4 directional positions for the selector.
* Use the 'DIR_' constants to index.
* Only used if the widget is selectable (see 'GenFlags[]').

void GetSelTextOverride(char32[] buf);
* Gets the selected text override for this widget.
* If the buffer provided is too small, it will *automatically be resized to fit*.
void SetSelTextOverride(char32[] str);
* Sets the selected text override for this widget.
* A blank string represents no override.

//Selector override stuff
int SelectorDestX;
int SelectorDestY;
int SelectorDestW;
int SelectorDestH;
* The X/Y/W/H offsets for the selector on this widget,
* if the selector is overridden (see 'GenFlags[]').
* These values will REPLACE the x/y/w/h that the
* selector would normally draw to.

int SelectorWid[2];
int SelectorHei[2];
int SelectorTile[2];
int SelectorCSet[2];
int SelectorFlashCSet[2];
int SelectorFrames[2];
int SelectorASpeed[2];
int SelectorDelay[2];
* The pixel-size, tile, cset/flashcset, and animation information for
* the two selector overrides.
* These will be used by the selector on this widget,
* if the selector is overridden (see 'GenFlags[]').

//Press Script stuff
int PressScript;
* The generic script that will run when a specified button
* is pressed while this widget is selected.

untyped PressInitD[8];
* The 8 InitD[] args for the PressScript

bool BtnPressScript[8];
* Use the 'INTBTN_' constants to index this array.
* The 'true' buttons here, when pressed while this
* widget is selected, run the press script.

//Press PageChange Stuff

bool BtnPageChange[8];
* Use the 'INTBTN_' constants to index this array.
* The 'true' buttons here, when pressed while this
* widget is selected, change the current page
* based on the PageMode.

int PageMode;
* The type of page change that will occur when a specified
* button is pressed while this widget is selected.
* Use the 'SUB_PGMODE_' constants for this value.

int TargetPage;
* The page to change to when using PageMode of 'SUB_PGMODE_TARG'

//Transition info
int PageTransType;
* The transition type for the PageMode transition.
* Compare with the 'TRANS_TY_' constants.

int PageTransSFX;
* The transition sfx for the PageMode transition.

bool PageTransFlags[];
* The flags for the PageMode transition.
* Use the 'TRANSFLAG_' constants to access these.

int PageTransArgs[];
* The arguments used for the PageMode transition.
* Use the 'TRANS_*_ARG_' constants to access these

//
// TYPE SPECIFIC
// The following are only available for
// some widget types, as listed.
//



////////////////////////////////////
////////////////////////////////////
________ ___. .__
\______ \ ____\_ |__ __ __ ____ ____ |__| ____ ____
| | \_/ __ \| __ \| | \/ ___\ / ___\| |/ \ / ___\
Expand All @@ -8820,7 +8947,7 @@ Functions for debugging, and raw access to the internal ZASM stack and mechanics

/////////////////
/// Debug-> ///
///////////////// // Debug
///////////////// Debug

bool Testing;
* Returns true if this instance of ZC was launched from the 'Quest->Test' option in ZQ.
Expand Down
37 changes: 37 additions & 0 deletions resources/include/std_zh/std_constants.zh
Original file line number Diff line number Diff line change
Expand Up @@ -4009,5 +4009,42 @@ enum //Transition Flags

DEFINE SUBSEL_FLAG_NO_NONEQUIP = 0x01;
DEFINE SUBSEL_FLAG_NEED_ITEM = 0x02;

enum //Widget Types
{
SUBWIDG_NULL, SUBWIDG_FRAME, SUBWIDG_TEXT, SUBWIDG_LINE, SUBWIDG_RECT,
SUBWIDG_TIME, SUBWIDG_MMETER, SUBWIDG_LMETER, SUBWIDG_BTNITM, SUBWIDG_COUNTER,
SUBWIDG_OLDCTR, SUBWIDG_MMAPTITLE, SUBWIDG_MMAP, SUBWIDG_LMAP, SUBWIDG_BGCOLOR,
SUBWIDG_ITEMSLOT, SUBWIDG_MCGUFF_FRAME, SUBWIDG_MCGUFF, SUBWIDG_TILEBLOCK, SUBWIDG_MINITILE,
SUBWIDG_SELECTOR, SUBWIDG_LGAUGE, SUBWIDG_MGAUGE, SUBWIDG_TEXTBOX, SUBWIDG_SELECTEDTEXT,
SUBWIDG_MISCGAUGE, SUBWIDG_BTNCOUNTER,
SUBWIDG_MAX
};

enum //Visibility Flags
{
SUBVISIB_CLOSED, //Visible while the active subscreen is closed
SUBVISIB_OPEN, //Visible while the active subscreen is open
SUBVISIB_SCROLLING, //Visible while the active subscreen is opening/closing
SUBVISIB_NO_MSGSTR, //Hide while a message string is displaying
SUBVISIB_MAX
};

enum //Widget genflags
{
SUBW_GENFL_SELECTABLE,
SUBW_GENFL_PGMODE_NOWRAP,
SUBW_GENFL_SELECTOR_OVERRIDE,
SUBW_GENFL_MAX
};

enum //Page Modes
{
SUB_PGMODE_NONE, //no page change
SUB_PGMODE_NEXT, //next page
SUB_PGMODE_PREV, //previous page
SUB_PGMODE_TARG, //specified page
SUB_PGMODE_MAX
};
//} End section for engine subscreen stuff

5 changes: 4 additions & 1 deletion src/new_subscr.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,18 +231,21 @@ enum //PGGOTO modes
PGGOTO_NONE,
PGGOTO_NEXT,
PGGOTO_PREV,
PGGOTO_TRG
PGGOTO_TRG,
PGGOTO_MAX
};

//when to display an element
#define sspUP 0x01
#define sspDOWN 0x02
#define sspSCROLLING 0x04
#define sspNOMSGSTR 0x08
#define sspNUM 4

#define SUBSCRFLAG_SELECTABLE 0x00000001
#define SUBSCRFLAG_PGGOTO_NOWRAP 0x00000002
#define SUBSCRFLAG_SELOVERRIDE 0x00000004
#define SUBSCRFLAG_GEN_COUNT 3

#define SUBSCRFLAG_SPEC_01 0x00000001
#define SUBSCRFLAG_SPEC_02 0x00000002
Expand Down
62 changes: 39 additions & 23 deletions src/parser/ByteCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2335,25 +2335,41 @@ string ZScript::VarToString(int32_t ID)
case SUBPGWIDGETS: return "SUBPGWIDGETS";
case SUBPGSUBDATA: return "SUBPGSUBDATA";
case SUBPGCURSORPOS: return "SUBPGCURSORPOS";
case RESRVD_VAR_EMILY_92: return "RESRVD_VAR_EMILY_92";
case RESRVD_VAR_EMILY_93: return "RESRVD_VAR_EMILY_93";
case RESRVD_VAR_EMILY_94: return "RESRVD_VAR_EMILY_94";
case RESRVD_VAR_EMILY_95: return "RESRVD_VAR_EMILY_95";
case RESRVD_VAR_EMILY_96: return "RESRVD_VAR_EMILY_96";
case RESRVD_VAR_EMILY_97: return "RESRVD_VAR_EMILY_97";
case RESRVD_VAR_EMILY_98: return "RESRVD_VAR_EMILY_98";
case RESRVD_VAR_EMILY_99: return "RESRVD_VAR_EMILY_99";
case RESRVD_VAR_EMILY_100: return "RESRVD_VAR_EMILY_100";
case RESRVD_VAR_EMILY_101: return "RESRVD_VAR_EMILY_101";
case RESRVD_VAR_EMILY_102: return "RESRVD_VAR_EMILY_102";
case RESRVD_VAR_EMILY_103: return "RESRVD_VAR_EMILY_103";
case RESRVD_VAR_EMILY_104: return "RESRVD_VAR_EMILY_104";
case RESRVD_VAR_EMILY_105: return "RESRVD_VAR_EMILY_105";
case RESRVD_VAR_EMILY_106: return "RESRVD_VAR_EMILY_106";
case RESRVD_VAR_EMILY_107: return "RESRVD_VAR_EMILY_107";
case RESRVD_VAR_EMILY_108: return "RESRVD_VAR_EMILY_108";
case RESRVD_VAR_EMILY_109: return "RESRVD_VAR_EMILY_109";
case RESRVD_VAR_EMILY_110: return "RESRVD_VAR_EMILY_110";
case SUBWIDGTYPE: return "SUBWIDGTYPE";
case SUBWIDGINDEX: return "SUBWIDGINDEX";
case SUBWIDGPAGE: return "SUBWIDGPAGE";
case SUBWIDGPOS: return "SUBWIDGPOS";
case SUBWIDGPOSES: return "SUBWIDGPOSES";
case SUBWIDGPOSFLAG: return "SUBWIDGPOSFLAG";
case SUBWIDGX: return "SUBWIDGX";
case SUBWIDGY: return "SUBWIDGY";
case SUBWIDGW: return "SUBWIDGW";
case SUBWIDGH: return "SUBWIDGH";
case SUBWIDGGENFLAG: return "SUBWIDGGENFLAG";
case SUBWIDGFLAG: return "SUBWIDGFLAG";
case SUBWIDGSELECTORDSTX: return "SUBWIDGSELECTORDSTX";
case SUBWIDGSELECTORDSTY: return "SUBWIDGSELECTORDSTY";
case SUBWIDGSELECTORDSTW: return "SUBWIDGSELECTORDSTW";
case SUBWIDGSELECTORDSTH: return "SUBWIDGSELECTORDSTH";
case SUBWIDGSELECTORWID: return "SUBWIDGSELECTORWID";
case SUBWIDGSELECTORHEI: return "SUBWIDGSELECTORHEI";
case SUBWIDGSELECTORTILE: return "SUBWIDGSELECTORTILE";

case SUBWIDGSELECTORCSET: return "SUBWIDGSELECTORCSET";
case SUBWIDGSELECTORFLASHCSET: return "SUBWIDGSELECTORFLASHCSET";
case SUBWIDGSELECTORFRM: return "SUBWIDGSELECTORFRM";
case SUBWIDGSELECTORASPD: return "SUBWIDGSELECTORASPD";
case SUBWIDGSELECTORDELAY: return "SUBWIDGSELECTORDELAY";
case SUBWIDGPRESSSCRIPT: return "SUBWIDGPRESSSCRIPT";
case SUBWIDGPRESSINITD: return "SUBWIDGPRESSINITD";
case SUBWIDGBTNPRESS: return "SUBWIDGBTNPRESS";
case SUBWIDGBTNPG: return "SUBWIDGBTNPG";
case SUBWIDGPGMODE: return "SUBWIDGPGMODE";
case SUBWIDGPGTARG: return "SUBWIDGPGTARG";
case SUBWIDGTRANSPGTY: return "SUBWIDGTRANSPGTY";
case SUBWIDGTRANSPGSFX: return "SUBWIDGTRANSPGSFX";
case SUBWIDGTRANSPGFLAGS: return "SUBWIDGTRANSPGFLAGS";
case SUBWIDGTRANSPGARGS: return "SUBWIDGTRANSPGARGS";

default:
{
Expand Down Expand Up @@ -6755,13 +6771,13 @@ string OSubscrPgDelete::toString() const
{
return "SUBPAGE_DELETE";
}
string OReservedEmily_9::toString() const
string OGetSubWidgSelTxtOverride::toString() const
{
return "RESRVD_OP_EMILY_9";
return "SUBWIDG_GET_SELTEXT_OVERRIDE";
}
string OReservedEmily_10::toString() const
string OSetSubWidgSelTxtOverride::toString() const
{
return "RESRVD_OP_EMILY_10";
return "SUBWIDG_SET_SELTEXT_OVERRIDE";
}
string OReservedEmily_11::toString() const
{
Expand Down

0 comments on commit 5e8e6dc

Please sign in to comment.