Skip to content

Commit

Permalink
feat: 'subscreendata' datatype implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilyV99 committed Sep 9, 2023
1 parent 233773c commit 6402650
Show file tree
Hide file tree
Showing 17 changed files with 1,576 additions and 223 deletions.
1 change: 1 addition & 0 deletions modules/zscript/ParserSrc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ src/parser/symbols/BottleTypeSymbols.cpp
src/parser/symbols/BottleShopSymbols.cpp
src/parser/symbols/GenericDataSymbols.cpp
src/parser/symbols/PortalSymbols.cpp
src/parser/symbols/SubscreenDataSymbols.cpp

## End of ZQuest ZScript module
)
Expand Down
144 changes: 143 additions & 1 deletion resources/docs/ZScript_Additions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,13 @@ untyped : A special datatype that can be cast to and from any other type.
savedportal :
Object type for storing portal data that saves with the save file (See ZScript_Docs.html)

subscreendata :
Object type for reading/modifying engine Subscreens
subscreenpage :
Object type for reading/modifying engine Subscreen Pages
subscreenwidget :
Object type for reading/modifying engine Subscreen Widgets

//Planned/Incomplete
warpringdata : t/b/a
(Planned) Access to all Warpring Editor data.
Expand All @@ -736,7 +743,6 @@ untyped : A special datatype that can be cast to and from any other type.
(Planned) Access to all global game data (game->, in source)
cheatsdata : t/b/a
(Planned) Access to cheat code information.
subscreendata: t/b/a


///////////////////////
Expand Down Expand Up @@ -3640,6 +3646,19 @@ genericdata LoadGenericData(int scriptslot);
* Loads the 'genericdata' pointer referencing the specified generic script slot.
* Note that '0' is invalid.

subscreendata LoadASubData(int id);
subscreendata LoadPSubData(int id);
subscreendata LoadOSubData(int id);
* Loads the 'subscreendata' pointer for the specified active/passive/overlay subscreen.

int NumActiveSubscreens();
int NumPassiveSubscreens();
int NumOverlaySubscreens();
* Returns the total number of active/passive/overlay subscreens

bool ActiveSubscreenOpen;
* Read-only. True if the active subscreen is currently open.

bool TypingMode;
* If set true, all keyboard presses that would ordinarily perform an in-engine action are suppressed.
* Example: The 'z' key is bound to the 'A Button'; the user presses the 'z' key.
Expand Down Expand Up @@ -8626,6 +8645,129 @@ void Own();
* When the script terminates (at the same time any Local Arrays in the script
* are cleared), the pointer will be automatically freed.

/////////////////////
// subscreendata //
///////////////////// subscreendata

//For any subscreen type:

int CurPage;
* The currently selected page.

int NumPages;
* The total number of pages

subscreenpage Pages[];
* Read-only. The array containing the pages

int Type;
* Read-only. Compare with the 'SSTYPE_' constants.
* The type of the subscreen.

bool Flags[];
* The flags of the subscreen. Use the 'SSFL_*_' constants to access.

void GetName(char32[] buf);
* Puts the subscreen's name in the buffer.
* If the buffer is too small, resizes it for you!

void SetName(char32[] buf);
* Sets the subscreen's name from the buffer.

//
// Only on the CURRENTLY OPEN ACTIVE SUBSCREEN:
//
int TransClock;
* The timer clock used by the currently active transition.
int TransType;
* The transition type currently active.
* Compare with the 'TRANS_TY_' constants.
* Will be 'TRANS_TY_NONE' if no transition is currently active.
* Write this to forcibly start/stop a transition.
bool TransFlags[];
* The flags for the current transition.
* Use the 'TRANSFLAG_' constants to access these.
int TransArgs[];
* The arguments used for the current transition.
* Use the 'TRANS_*_ARG_' constants to access these
int TransFromPage;
int TransToPage;
* The page the currently active transition is going from/to.

//
// Only on ACTIVE subscreens:
//

int CursorPos;
* The position value of the selector.

int Script;
* The subscreen's script.
untyped InitD[8];
* The subscreen's InitD[] parameters

bool BtnPageLeft[8];
* Use the 'INTBTN_' constants to index this array.
* The 'true' buttons here, when pressed, change pages leftwards.
bool BtnPageRight[8];
* Use the 'INTBTN_' constants to index this array.
* The 'true' buttons here, when pressed, change pages rightwards.



int TransLeftType;
int TransRightType;
* The transition type for left/right transitions.
* Compare with the 'TRANS_TY_' constants.

int TransLeftSFX;
int TransRightSFX;
* The transition sfx for left/right transitions.

bool TransLeftFlags[];
bool TransRightFlags[];
* The flags for left/right transitions.
* Use the 'TRANSFLAG_' constants to access these.

int TransLeftArgs[];
int TransRightArgs[];
* The arguments used for left/right transitions.
* Use the 'TRANS_*_ARG_' constants to access these


int SelectorDestX;
int SelectorDestY;
int SelectorDestW;
int SelectorDestH;
* The X/Y/W/H offsets for the selector on this subscreen,
* if the selector is overridden (see `Flags[]`).
* These values will be ADDED to 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 subscreen,
* if the selector is overridden (see `Flags[]`).

/////////////////////
// subscreenpage //
///////////////////// subscreenpage


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



________ ___. .__
\______ \ ____\_ |__ __ __ ____ ____ |__| ____ ____
| | \_/ __ \| __ \| | \/ ___\ / ___\| |/ \ / ___\
Expand Down
62 changes: 62 additions & 0 deletions resources/include/std_zh/std_constants.zh
Original file line number Diff line number Diff line change
Expand Up @@ -3947,3 +3947,65 @@ enum
DEFINE CIID_FLAG_CHECKCOST = 0x01;
DEFINE CIID_FLAG_CHECKJINX = 0x02;
DEFINE CIID_FLAG_CHECKBUNNY = 0x04;

//{ This section for engine subscreen stuff
enum //Subscreen Types
{
SSTYPE_ACTIVE,
SSTYPE_PASSIVE,
SSTYPE_OVERLAY,
SSTYPE_MAX
};

//Subscreen Flags
enum
{
SSFL_ACTIVE_NOPAGEWRAP,
SSFL_ACTIVE_OVERRIDE_SELECTOR,
SSFL_ACTIVE_MAX
};
enum
{
SSFL_PASSIVE_MAX
};
enum
{
SSFL_OVERLAY_MAX
};

enum //Transition Types
{
TRANS_TY_NONE = -1,
TRANS_TY_INSTANT,
TRANS_TY_SLIDE,
TRANS_TY_PIXEL,
TRANS_TY_MAX
};

//Transition arguments
enum
{
TRANS_INSTANT_ARG_MAX
};
enum
{
TRANS_SLIDE_ARG_DIR,
TRANS_SLIDE_ARG_SPEED,
TRANS_SLIDE_ARG_MAX
};
enum
{
TRANS_PIXEL_ARG_INVERT,
TRANS_PIXEL_ARG_DURATION,
TRANS_PIXEL_ARG_XOFF,
TRANS_PIXEL_ARG_YOFF,
TRANS_PIXEL_ARG_MAX
};

enum //Transition Flags
{
TRANSFLAG_NO_HIDE_SELECTOR,
TRANSFLAG_MAX
};
//} End section for engine subscreen stuff

16 changes: 15 additions & 1 deletion src/new_subscr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const std::string subscr_infos[sstMAX] = {

SubscrTransition subscr_pg_transition;
int subscr_item_clk = 0, subscr_pg_clk = 0;
static byte subscr_pg_from, subscr_pg_to;
byte subscr_pg_from, subscr_pg_to;
static ZCSubscreen* subscr_anim = nullptr;

int subscr_override_clkoffsets[MAXITEMS];
Expand Down Expand Up @@ -928,6 +928,20 @@ byte SubscrTransition::num_args(byte ty)
}
return 0;
}
int32_t SubscrTransition::argScale(byte ty, byte ind)
{
switch(ty)
{
case sstrSLIDE:
switch(ind)
{
case 1:
return 1;
}
break;
}
return 10000;
}

SubscrWidget::SubscrWidget(byte ty) : SubscrWidget()
{
Expand Down
6 changes: 4 additions & 2 deletions src/new_subscr.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct ZCSubscreen;

extern SubscrTransition subscr_pg_transition;
extern int subscr_item_clk, subscr_pg_clk;
extern byte subscr_pg_from, subscr_pg_to;
extern bool subscr_itemless, subscr_pg_animating;

void subscrpg_clear_animation();
Expand Down Expand Up @@ -96,7 +97,7 @@ struct SubscrSelectorTileInfo
int32_t read(PACKFILE *f, word s_version);
int32_t write(PACKFILE *f) const;
};

#define SUBSCR_SELECTOR_NUMTILEINFO 2
struct SubscrSelectorInfo
{
int16_t x,y,w,h;
Expand All @@ -109,6 +110,7 @@ struct SubscrSelectorInfo

#define SUBSCR_TRANSITION_MAXARG 4
#define SUBSCR_TRANS_NOHIDESELECTOR 0x0001
#define SUBSCR_TRANS_NUMFLAGS 1
struct SubscrTransition
{
byte type;
Expand All @@ -121,6 +123,7 @@ struct SubscrTransition
int32_t read(PACKFILE *f, word s_version);
int32_t write(PACKFILE *f) const;
static byte num_args(byte ty);
static int32_t argScale(byte ty, byte ind);
};

enum //Transition types
Expand Down Expand Up @@ -1044,7 +1047,6 @@ struct ZCSubscreen

SubscrSelectorInfo selector_setting;

//!TODO Subscreen Scripts
word script;
int32_t initd[8];

Expand Down

0 comments on commit 6402650

Please sign in to comment.