Skip to content

Commit

Permalink
feat: Trigger flags relating to LItems (map,compass,etc)
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilyV99 committed Apr 14, 2024
1 parent f20ddc1 commit 42b8357
Show file tree
Hide file tree
Showing 23 changed files with 437 additions and 119 deletions.
6 changes: 6 additions & 0 deletions resources/docs/ZScript_Additions.txt
Expand Up @@ -7829,6 +7829,12 @@ int TrigGroupVal;
* The value used for the `TRIGFLAG_TGROUP_LESS` and `TRIGFLAG_TGROUP_GREATER` flags.
* 0-65535, inclusive.

int TrigLItems;
* 'LI_' flags used by the `TRIGFLAG_LITEM_REQUIRE`,`TRIGFLAG_LITEM_INV_REQUIRE`,`TRIGFLAG_LITEM_SET`,`TRIGFLAG_LITEM_UNSET` flags.
int TrigDMapLvl;
* The 'Level' used by 'TrigLItems'.
* -1 represents the 'current level', otherwise a valid dmap level indicates that level.

int TrigGenScript;
* When triggered, this generic script will be run in the 'RunFrozen' mode.

Expand Down
4 changes: 4 additions & 0 deletions resources/include/std_zh/std_constants.zh
Expand Up @@ -3621,6 +3621,10 @@ enum ComboTrigFlag
TRIGFLAG_TOGGLE_DARKNESS, //Effects->Toggle Darkness
TRIGFLAG_REQ_DARKNESS, //Other->Req. Darkness
TRIGFLAG_REQ_NO_DARKNESS, //Other->Req. Darkness
TRIGFLAG_LITEM_REQUIRE, //Counters/Items->Require All
TRIGFLAG_LITEM_INV_REQUIRE, //Counters/Items->Require Not All
TRIGFLAG_LITEM_SET, //Counters/Items->'->Set'
TRIGFLAG_LITEM_UNSET, //Counters/Items->'->Unset'

TRIGFLAG_MAX_IN_USE,
TRIGFLAG_MAX = 32*6
Expand Down
8 changes: 8 additions & 0 deletions src/base/combo.cpp
Expand Up @@ -64,6 +64,8 @@ bool newcombo::is_blank(bool ignoreEff)
if(trig_genscr) return false;
if(trig_group) return false;
if(trig_group_val) return false;
if(trig_levelitems) return false;
if(trigdmlevel > -1) return false;
if(!label.empty()) return false;
for(auto q = 0; q < NUM_COMBO_ATTRIBYTES; ++q)
if(attribytes[q]) return false;
Expand Down Expand Up @@ -188,6 +190,10 @@ void newcombo::advpaste(newcombo const& other, bitstring const& flags)
triggerflags[q] = other.triggerflags[q];
triggerlevel = other.triggerlevel;
triggerbtn = other.triggerbtn;
prompt_cid = other.prompt_cid;
prompt_cs = other.prompt_cs;
prompt_x = other.prompt_x;
prompt_y = other.prompt_y;
triggeritem = other.triggeritem;
trigtimer = other.trigtimer;
trigsfx = other.trigsfx;
Expand All @@ -211,6 +217,8 @@ void newcombo::advpaste(newcombo const& other, bitstring const& flags)
trig_genscr = other.trig_genscr;
trig_group = other.trig_group;
trig_group_val = other.trig_group_val;
trig_levelitems = other.trig_levelitems;
trigdmlevel = other.trigdmlevel;
}
if(flags.get(CMB_ADVP_LIFTING))
{
Expand Down
10 changes: 6 additions & 4 deletions src/base/combo.h
Expand Up @@ -96,6 +96,8 @@ struct newcombo
word trig_genscr;
byte trig_group;
word trig_group_val;
byte trig_levelitems;
int16_t trigdmlevel = -1;
byte liftflags;
byte liftlvl;
byte liftsfx;
Expand Down Expand Up @@ -279,10 +281,10 @@ struct newcombo
#define combotriggerTOGGLEDARK 0x00400000
#define combotriggerCOND_DARK 0x00800000
#define combotriggerCOND_NODARK 0x01000000
//#define combotrigger 0x02000000
//#define combotrigger 0x04000000
//#define combotrigger 0x08000000
//#define combotrigger 0x10000000
#define combotriggerLITEM_COND 0x02000000
#define combotriggerLITEM_REVCOND 0x04000000
#define combotriggerLITEM_SET 0x08000000
#define combotriggerLITEM_UNSET 0x10000000
//#define combotrigger 0x20000000
//#define combotrigger 0x40000000
//#define combotrigger 0x80000000
Expand Down
16 changes: 16 additions & 0 deletions src/base/general.h
Expand Up @@ -355,5 +355,21 @@ direction GET_YDIR(zfix const& sign);
direction GET_DIR(zfix const& dx, zfix const& dy);
#define NORMAL_DIR(dir) ((dir >= 0 && dir < 16) ? normalDir[dir] : dir_invalid)



struct CheckListInfo
{
std::string name, info;
byte flags;
static const byte DISABLED = 0x1;

CheckListInfo(std::string name = "", std::string info = "")
: name(std::move(name)), info(std::move(info)), flags(0)
{}
CheckListInfo(byte flags, std::string name = "", std::string info = "")
: name(std::move(name)), info(std::move(info)), flags(flags)
{}
};

#endif

15 changes: 9 additions & 6 deletions src/base/zdefs.h
Expand Up @@ -210,7 +210,7 @@ enum {ENC_METHOD_192B104=0, ENC_METHOD_192B105, ENC_METHOD_192B185, ENC_METHOD_2
#define V_STRINGS 10
#define V_MISC 16
#define V_TILES 3 //2 is a int32_t, max 214500 tiles (ZScript upper limit)
#define V_COMBOS 45
#define V_COMBOS 46
#define V_CSETS 5 //palette data
#define V_MAPS 30
#define V_DMAPS 21
Expand Down Expand Up @@ -349,11 +349,14 @@ if(close_button_quit) \
#define ZQ_MAXDATA 20

// lvlitems flags
#define liTRIFORCE 1
#define liMAP 2
#define liCOMPASS 4
#define liBOSS 8
#define liBOSSKEY 16
#define liTRIFORCE 0x01
#define liMAP 0x02
#define liCOMPASS 0x04
#define liBOSS 0x08
#define liBOSSKEY 0x10

#define liALLUSED 0x1F
#define liALL 0xFF

// sprite drawing flag bits
#define sprdrawflagALWAYSOLDDRAWS 1
Expand Down
33 changes: 25 additions & 8 deletions src/dialog/checklist.cpp
Expand Up @@ -4,41 +4,58 @@
#include <utility>

bool call_checklist_dialog(string const& title,
vector<def_pair<string,string>> const& flagnames, bitstring& flags)
vector<CheckListInfo> const& flagnames, bitstring& flags)
{
bool ret = false;
ChecklistDialog(title, flagnames, flags, ret).show();
return ret;
}
bool call_checklist_dialog(string const& title,
vector<CheckListInfo> const& flagnames, int32_t& flags)
{
bitstring bitstr;
for(int q = 0; q < 32; ++q)
if(flags & (1<<q))
bitstr.set(q, true);
bool ret = false;
ChecklistDialog(title, flagnames, bitstr, ret).show();
flags = 0;
for(int q = 0; q < 32; ++q)
if(bitstr.get(q))
flags |= (1<<q);
return ret;
}

ChecklistDialog::ChecklistDialog(string const& title,
vector<def_pair<string,string>> const& flagnames, bitstring& flags, bool& confirm):
vector<CheckListInfo> const& flagnames, bitstring& flags, bool& confirm):
d_title(title), flagnames(flagnames), flags(flags), confirm(confirm)
{}

std::shared_ptr<GUI::Widget> ChecklistDialog::view()
{
using namespace GUI::Builder;
using namespace GUI::Props;
auto grid = Columns<10>();
auto grid = (flagnames.size() > 5 && flagnames.size() < 20)
? GUI::Grid::columns((flagnames.size()+1)/2)
: Columns<10>();
bool use_info = false;
for(uint q = 0; q < flagnames.size(); ++q)
if(flagnames[q].second.size())
if(!flagnames[q].info.empty())
{
use_info = true;
break;
}
for(uint q = 0; q < flagnames.size(); ++q)
{
auto const& pair = flagnames[q];
auto cbox = Checkbox(text = pair.first, hAlign = 0.0,
checked = flags.get(q),
auto const& ref = flagnames[q];
auto cbox = Checkbox(text = ref.name.empty() ? "--" : ref.name, hAlign = 0.0,
checked = flags.get(q), disabled = ref.flags & CheckListInfo::DISABLED,
onToggleFunc = [&,q](bool state)
{
flags.set(q, state);
});
if(use_info)
grid->add(Row(padding = 0_px, hAlign = 0.0, pair.second.empty() ? DINFOBTN() : INFOBTN(pair.second), cbox));
grid->add(Row(padding = 0_px, hAlign = 0.0, ref.info.empty() ? DINFOBTN() : INFOBTN(ref.info), cbox));
else grid->add(cbox);
}

Expand Down
4 changes: 2 additions & 2 deletions src/dialog/checklist.h
Expand Up @@ -19,14 +19,14 @@ class ChecklistDialog: public GUI::Dialog<ChecklistDialog>
public:
enum class message { REFR_INFO, OK, CANCEL };

ChecklistDialog(string const& title, vector<def_pair<string,string>> const& flagnames,
ChecklistDialog(string const& title, vector<CheckListInfo> const& flagnames,
bitstring& flags, bool& confirm);

std::shared_ptr<GUI::Widget> view() override;
virtual bool handleMessage(const GUI::DialogMessage<message>& msg);
protected:
string d_title;
vector<def_pair<string,string>> const& flagnames;
vector<CheckListInfo> const& flagnames;
bitstring& flags;
bool& confirm;
std::shared_ptr<GUI::Window> window;
Expand Down

0 comments on commit 42b8357

Please sign in to comment.