diff --git a/_module/ncs/alice_shop.ncs b/_module/ncs/alice_shop.ncs index bc99cae..e4b25c5 100644 Binary files a/_module/ncs/alice_shop.ncs and b/_module/ncs/alice_shop.ncs differ diff --git a/_module/ncs/assplode.ncs b/_module/ncs/assplode.ncs index 12f13fe..ecc788c 100644 Binary files a/_module/ncs/assplode.ncs and b/_module/ncs/assplode.ncs differ diff --git a/_module/ncs/client_enter_cs.ncs b/_module/ncs/client_enter_cs.ncs index 4e85623..3fdb356 100644 Binary files a/_module/ncs/client_enter_cs.ncs and b/_module/ncs/client_enter_cs.ncs differ diff --git a/_module/ncs/gelhn_hanselfast.ncs b/_module/ncs/gelhn_hanselfast.ncs index 3707a2d..29ca132 100644 Binary files a/_module/ncs/gelhn_hanselfast.ncs and b/_module/ncs/gelhn_hanselfast.ncs differ diff --git a/_module/ncs/kgard_2_kwater.ncs b/_module/ncs/kgard_2_kwater.ncs index ac50623..391bf60 100644 Binary files a/_module/ncs/kgard_2_kwater.ncs and b/_module/ncs/kgard_2_kwater.ncs differ diff --git a/_module/ncs/kulkingspawn.ncs b/_module/ncs/kulkingspawn.ncs index 06ce81e..656bf0f 100644 Binary files a/_module/ncs/kulkingspawn.ncs and b/_module/ncs/kulkingspawn.ncs differ diff --git a/_module/ncs/leo_shadowjump.ncs b/_module/ncs/leo_shadowjump.ncs index 2d71830..7b3c6a8 100644 Binary files a/_module/ncs/leo_shadowjump.ncs and b/_module/ncs/leo_shadowjump.ncs differ diff --git a/_module/ncs/locktimer.ncs b/_module/ncs/locktimer.ncs index 3eb9fa4..2d6b8aa 100644 Binary files a/_module/ncs/locktimer.ncs and b/_module/ncs/locktimer.ncs differ diff --git a/_module/ncs/ls_atropos.ncs b/_module/ncs/ls_atropos.ncs index 2cf4394..ff70802 100644 Binary files a/_module/ncs/ls_atropos.ncs and b/_module/ncs/ls_atropos.ncs differ diff --git a/_module/ncs/ls_clotho.ncs b/_module/ncs/ls_clotho.ncs index 321d9ca..04c08b4 100644 Binary files a/_module/ncs/ls_clotho.ncs and b/_module/ncs/ls_clotho.ncs differ diff --git a/_module/ncs/ls_lachesis.ncs b/_module/ncs/ls_lachesis.ncs index 964a14f..7d3e150 100644 Binary files a/_module/ncs/ls_lachesis.ncs and b/_module/ncs/ls_lachesis.ncs differ diff --git a/_module/ncs/madspark.ncs b/_module/ncs/madspark.ncs index a858b8f..aa7587c 100644 Binary files a/_module/ncs/madspark.ncs and b/_module/ncs/madspark.ncs differ diff --git a/_module/ncs/mod_gui.ncs b/_module/ncs/mod_gui.ncs index 410d992..da11223 100644 Binary files a/_module/ncs/mod_gui.ncs and b/_module/ncs/mod_gui.ncs differ diff --git a/_module/ncs/mod_nui.ncs b/_module/ncs/mod_nui.ncs index aaa3cee..aefbeb1 100644 Binary files a/_module/ncs/mod_nui.ncs and b/_module/ncs/mod_nui.ncs differ diff --git a/_module/ncs/obj_us_chest.ncs b/_module/ncs/obj_us_chest.ncs index fe3f334..f95d9ba 100644 Binary files a/_module/ncs/obj_us_chest.ncs and b/_module/ncs/obj_us_chest.ncs differ diff --git a/_module/ncs/rall_open_chest.ncs b/_module/ncs/rall_open_chest.ncs index fd6d804..4d95dae 100644 Binary files a/_module/ncs/rall_open_chest.ncs and b/_module/ncs/rall_open_chest.ncs differ diff --git a/_module/ncs/sail_inchyre_h1.ncs b/_module/ncs/sail_inchyre_h1.ncs index 9acf968..f788738 100644 Binary files a/_module/ncs/sail_inchyre_h1.ncs and b/_module/ncs/sail_inchyre_h1.ncs differ diff --git a/_module/ncs/shop_a_guild.ncs b/_module/ncs/shop_a_guild.ncs index 0d0fbfa..acdea1d 100644 Binary files a/_module/ncs/shop_a_guild.ncs and b/_module/ncs/shop_a_guild.ncs differ diff --git a/_module/ncs/shop_aman_armour.ncs b/_module/ncs/shop_aman_armour.ncs index 965433b..563d66c 100644 Binary files a/_module/ncs/shop_aman_armour.ncs and b/_module/ncs/shop_aman_armour.ncs differ diff --git a/_module/ncs/shop_hatvendor.ncs b/_module/ncs/shop_hatvendor.ncs index 55304fe..a9fb22d 100644 Binary files a/_module/ncs/shop_hatvendor.ncs and b/_module/ncs/shop_hatvendor.ncs differ diff --git a/_module/ncs/shop_magic_hur.ncs b/_module/ncs/shop_magic_hur.ncs index d7b4ef1..ff1b8ba 100644 Binary files a/_module/ncs/shop_magic_hur.ncs and b/_module/ncs/shop_magic_hur.ncs differ diff --git a/_module/ncs/shop_smithng.ncs b/_module/ncs/shop_smithng.ncs index e5b76d8..05ea920 100644 Binary files a/_module/ncs/shop_smithng.ncs and b/_module/ncs/shop_smithng.ncs differ diff --git a/_module/ncs/trashcollect.ncs b/_module/ncs/trashcollect.ncs index d115e38..ba8ce37 100644 Binary files a/_module/ncs/trashcollect.ncs and b/_module/ncs/trashcollect.ncs differ diff --git a/_module/ncs/vaxtrigger.ncs b/_module/ncs/vaxtrigger.ncs index 6765b17..3f84a40 100644 Binary files a/_module/ncs/vaxtrigger.ncs and b/_module/ncs/vaxtrigger.ncs differ diff --git a/_module/nss/client_enter_cs.nss b/_module/nss/client_enter_cs.nss index 7856f5a..528e92e 100644 --- a/_module/nss/client_enter_cs.nss +++ b/_module/nss/client_enter_cs.nss @@ -13,12 +13,30 @@ #include "enterinc" #include "pqj_inc" #include "nwnx_webhook" +#include "nwnx_player" #include "inc_examine" #include "inc_gennui" //:: AmonBot Webhook const string NWNX_DISCORD_URL = "/api/webhooks/1187525263693725706/oRFVnrx9qq7mxmpwOaslNgaQoaVAchTlK-NGFOHv4_2fJMdl-AIAVfpid8L_Lm3gs3Qq/slack"; +void SetTlkOverrideForMaximumLevel(object oPC); + +void SetTlkOverrideForMaximumLevel(object oPC) +{ + int nLevel = GetHitDice(oPC); + + if (nLevel < 40) + { + NWNX_Player_SetTlkOverride(oPC, 315, ""); + } + else + { + NWNX_Player_SetTlkOverride(oPC, 315, "Next Level: " + IntToString((nLevel + 1) * nLevel * 500) + "\n"); + } +} + + void main() { //:: Declare Major Variables @@ -43,6 +61,9 @@ void main() SetLocalInt(oPC,"stables",1); GPA_HorseOCL(oPC); + +//:: Fix XP display for 40+ lvl PCs + SetTlkOverrideForMaximumLevel(oPC); // Make sure PC isn't set to Plot, for reasons SetPlotFlag(oPC, FALSE); diff --git a/_module/nss/nw_inc_gff.nss b/_module/nss/nw_inc_gff.nss new file mode 100644 index 0000000..533cf21 --- /dev/null +++ b/_module/nss/nw_inc_gff.nss @@ -0,0 +1,623 @@ +// This is a helper library for advanced use: It allows constructing arbitrary gff data. +// You can then spawn your object via JsonToObject(). +// +// The data format is the same as https://github.com/niv/neverwinter.nim@1.4.3+. +// +// Example: +// +// json j = GffCreateObject(OBJECT_TYPE_ITEM); +// j = GffAddInt(j, "BaseItem", BASE_ITEM_BELT); +// j = GffAddInt(j, "ModelPart1", 12); +// j = GffAddLocString(j, "LocalizedName", "hi!"); +// object belt = JsonToObject(j, GetLocation(OBJECT_SELF)); + + +const string GFF_FIELD_TYPE_STRUCT = "struct"; +const string GFF_FIELD_TYPE_LIST = "list"; +const string GFF_FIELD_TYPE_BYTE = "byte"; +const string GFF_FIELD_TYPE_CHAR = "char"; +const string GFF_FIELD_TYPE_WORD = "word"; +const string GFF_FIELD_TYPE_SHORT = "short"; +const string GFF_FIELD_TYPE_DWORD = "dword"; +const string GFF_FIELD_TYPE_INT = "int"; +const string GFF_FIELD_TYPE_DWORD64 = "dword64"; +const string GFF_FIELD_TYPE_INT64 = "int64"; +const string GFF_FIELD_TYPE_FLOAT = "float"; +const string GFF_FIELD_TYPE_DOUBLE = "double"; +const string GFF_FIELD_TYPE_RESREF = "resref"; +const string GFF_FIELD_TYPE_STRING = "cexostring"; +const string GFF_FIELD_TYPE_LOC_STRING = "cexolocstring"; + + +// Create a empty object of the given type. You need to manually fill in all +// GFF data with GffAddXXX. This will require understanding of the GFF file format +// and what data fields each object type requires. +json GffCreateObject(int nObjectType); +// Create a combined area format(CAF) object. You need to manually create the ARE and GIT objects with their required data fields. +json GffCreateArea(json jARE, json jGIT); + +// Returns the OBJECT_TYPE_* of jGff. +// Note: Will return 0 for invalid object types, including areas. +int GffGetObjectType(json jGff); +// Returns TRUE if jGff is a combined area format(CAF) object. +int GffGetIsArea(json jGff); + +// Returns TRUE if a field named sLabel of sType exists in jGff. +// * sLabel: Can be a json pointer(path) without the starting /, see the documentation of JsonPointer() for details. +// * sType: An optional GFF_FIELD_TYPE_*, leave empty to check if sLabel exists regardless of type. +int GffGetFieldExists(json jGff, string sLabel, string sType = ""); + + +// Add a new field, will overwrite any existing fields with the same label even if the type is different. +// Returns a json null value on error with GetJsonError() filled in. +// +// sLabel can be a json pointer(path) without the starting /, see the documentation of JsonPointer() for details. +// For example, to add the tag of an area to an empty combined area format(CAF) object you can do the following: +// json jArea = GffCreateArea(JsonObject(), JsonObject()); +// jArea = GffAddString(jArea, "ARE/value/Tag", "AREA_TAG"); + +json GffAddStruct(json jGff, string sLabel, json jStruct, int nType = -1); +json GffAddList(json jGff, string sLabel, json jList); +json GffAddByte(json jGff, string sLabel, int v); +json GffAddChar(json jGff, string sLabel, int v); +json GffAddWord(json jGff, string sLabel, int v); +json GffAddShort(json jGff, string sLabel, int v); +// Note: Only data of type int32 will fit, because that's all that NWScript supports. +json GffAddDword(json jGff, string sLabel, int v); +json GffAddInt(json jGff, string sLabel, int v); +// Note: Only data of type int32 will fit, because that's all that NWScript supports. +json GffAddDword64(json jGff, string sLabel, int v); +// Note: Only data of type int32 will fit, because that's all that NWScript supports. +json GffAddInt64(json jGff, string sLabel, int v); +json GffAddFloat(json jGff, string sLabel, float v); +// Note: Only data of type float will fit, because that's all that NWScript supports. +json GffAddDouble(json jGff, string sLabel, float v); +json GffAddResRef(json jGff, string sLabel, string v); +json GffAddString(json jGff, string sLabel, string v); +json GffAddLocString(json jGff, string sLabel, string v, int nStrRef = -1); + + +// Replace a field, the type must match and the field must exist. +// Returns a json null value on error with GetJsonError() filled in. +// +// sLabel can be a json pointer(path) without the starting /, see the documentation of JsonPointer() for details. +// For example, to replace the name of an area in a combined area format(CAF) object you can do the following: +// json jArea = ObjectToStruct(GetFirstArea()); +// jArea = GffReplaceLocString(jArea, "ARE/value/Name", "New Area Name"); + +json GffReplaceStruct(json jGff, string sLabel, json jStruct); +json GffReplaceList(json jGff, string sLabel, json jList); +json GffReplaceByte(json jGff, string sLabel, int v); +json GffReplaceChar(json jGff, string sLabel, int v); +json GffReplaceWord(json jGff, string sLabel, int v); +json GffReplaceShort(json jGff, string sLabel, int v); +// Note: Only data of type int32 will fit, because that's all that NWScript supports. +json GffReplaceDword(json jGff, string sLabel, int v); +json GffReplaceInt(json jGff, string sLabel, int v); +// Note: Only data of type int32 will fit, because that's all that NWScript supports. +json GffReplaceDword64(json jGff, string sLabel, int v); +// Note: Only data of type int32 will fit, because that's all that NWScript supports. +json GffReplaceInt64(json jGff, string sLabel, int v); +json GffReplaceFloat(json jGff, string sLabel, float v); +// Note: Only data of type float will fit, because that's all that NWScript supports. +json GffReplaceDouble(json jGff, string sLabel, float v); +json GffReplaceResRef(json jGff, string sLabel, string v); +json GffReplaceString(json jGff, string sLabel, string v); +json GffReplaceLocString(json jGff, string sLabel, string v, int nStrRef = -1); + + +// Remove a field, the type must match and the field must exist. +// Returns a json null value on error with GetJsonError() filled in. +// +// sLabel can be a json pointer(path) without the starting /, see the documentation of JsonPointer() for details. +// For example, to remove all placeables from an area in a combined area format(CAF) object you can do the following: +// json jArea = ObjectToStruct(GetFirstArea()); +// jArea = GffRemoveList(jArea, "GIT/value/Placeable List"); + +json GffRemoveStruct(json jGff, string sLabel); +json GffRemoveList(json jGff, string sLabel); +json GffRemoveByte(json jGff, string sLabel); +json GffRemoveChar(json jGff, string sLabel); +json GffRemoveWord(json jGff, string sLabel); +json GffRemoveShort(json jGff, string sLabel); +json GffRemoveDword(json jGff, string sLabel); +json GffRemoveInt(json jGff, string sLabel); +json GffRemoveDword64(json jGff, string sLabel); +json GffRemoveInt64(json jGff, string sLabel); +json GffRemoveFloat(json jGff, string sLabel); +json GffRemoveDouble(json jGff, string sLabel); +json GffRemoveResRef(json jGff, string sLabel); +json GffRemoveString(json jGff, string sLabel); +json GffRemoveLocString(json jGff, string sLabel); + + +// Get a field's value as json object. +// Returns a json null value on error with GetJsonError() filled in. +// +// Note: Json types do not implicitly convert between types, this means you cannot convert a JsonInt to a string with JsonGetString(), etc. +// You may need to check the type with JsonGetType() and then do the appropriate cast yourself. +// For GffGet*() functions the json type returned is noted in the function description. +// +// Example: +// INCORRECT: string s = JsonGetString(GffGetInt()); +// CORRECT: string s = IntToString(JsonGetInt(GffGetInt())); +// +// sLabel can be a json pointer(path) without the starting /, see the documentation of JsonPointer() for details. +// For example, to get the resref of an area in a combined area format(CAF) object you can do the following: +// json jResRef = GffGetResRef(ObjectToStruct(GetFirstArea()), "ARE/value/ResRef"); +// if (jResRef != JsonNull()) +// { +// string sResRef = JsonGetString(jResRef); +// } +// else +// WriteTimestampedLogEntry("Failed to get area ResRef: " + JsonGetError(jResRef)); + +// Returns the struct as JsonObject() on success. +json GffGetStruct(json jGff, string sLabel); +// Returns a JsonArray() with all the list elements on success. +json GffGetList(json jGff, string sLabel); +// Returns a JsonInt() on success. +json GffGetByte(json jGff, string sLabel); +// Returns a JsonInt() on success. +json GffGetChar(json jGff, string sLabel); +// Returns a JsonInt() on success. +json GffGetWord(json jGff, string sLabel); +// Returns a JsonInt() on success. +json GffGetShort(json jGff, string sLabel); +// Returns a JsonInt() on success. +json GffGetDword(json jGff, string sLabel); +// Returns a JsonInt() on success. +json GffGetInt(json jGff, string sLabel); +// Returns a JsonInt() on success. +json GffGetDword64(json jGff, string sLabel); +// Returns a JsonInt() on success. +json GffGetInt64(json jGff, string sLabel); +// Returns a JsonFloat() on success. +json GffGetFloat(json jGff, string sLabel); +// Returns a JsonFloat() on success. +json GffGetDouble(json jGff, string sLabel); +// Returns a JsonString() on success. +json GffGetResRef(json jGff, string sLabel); +// Returns a JsonString() on success. +json GffGetString(json jGff, string sLabel); +// Returns a JsonObject() on success. +// Key "0" will have a JsonString() with the string, if set. +// Key "id" will have a JsonInt() with the strref, if set. +json GffGetLocString(json jGff, string sLabel); + + +// *** Internal Helper Functions +json AddPatchOperation(json jPatchArray, string sOp, string sPath, json jValue) +{ + json jOperation = JsonObject(); + jOperation = JsonObjectSet(jOperation, "op", JsonString(sOp)); + jOperation = JsonObjectSet(jOperation, "path", JsonString(sPath)); + jOperation = JsonObjectSet(jOperation, "value", jValue); + return JsonArrayInsert(jPatchArray, jOperation); +} + +json GffAddField(json jGff, string sLabel, string sType, json jValue, int nType = -1) +{ + json jField = JsonObject(); + jField = JsonObjectSet(jField, "type", JsonString(sType)); + jField = JsonObjectSet(jField, "value", jValue); + if (sType == GFF_FIELD_TYPE_STRUCT && nType != -1) + jField = JsonObjectSet(jField, "__struct_id", JsonInt(nType)); + + return JsonPatch(jGff, AddPatchOperation(JsonArray(), "add", "/" + sLabel, jField)); +} + +json GffReplaceField(json jGff, string sLabel, string sType, json jValue) +{ + json jPatch = JsonArray(); + jPatch = AddPatchOperation(jPatch, "test", "/" + sLabel + "/type", JsonString(sType)); + jPatch = AddPatchOperation(jPatch, "replace", "/" + sLabel + "/value", jValue); + return JsonPatch(jGff, jPatch); +} + +json GffRemoveField(json jGff, string sLabel, string sType) +{ + json jPatch = JsonArray(); + jPatch = AddPatchOperation(jPatch, "test", "/" + sLabel + "/type", JsonString(sType)); + jPatch = AddPatchOperation(jPatch, "remove", "/" + sLabel, JsonNull()); + return JsonPatch(jGff, jPatch); +} + +json GffGetFieldType(json jGff, string sLabel) +{ + return JsonPointer(jGff, "/" + sLabel + "/type"); +} + +json GffGetFieldValue(json jGff, string sLabel) +{ + return JsonPointer(jGff, "/" + sLabel + "/value"); +} + +json GffGetField(json jGff, string sLabel, string sType) +{ + json jType = GffGetFieldType(jGff, sLabel); + if (jType == JsonNull()) + return jType; + else if (jType != JsonString(sType)) + return JsonNull("field type does not match"); + else + return GffGetFieldValue(jGff, sLabel); +} + +json GffLocString(string v, int nStrRef = -1) +{ + json jLocString = JsonObject(); + if (v != "") + jLocString = JsonObjectSet(jLocString, "0", JsonString(v)); // english/any + if (nStrRef != -1) + jLocString = JsonObjectSet(jLocString, "id", JsonInt(nStrRef)); + + return jLocString; +} +//*** + +json GffCreateObject(int nObjectType) +{ + string ot; + if (nObjectType == OBJECT_TYPE_CREATURE) ot = "UTC "; + else if (nObjectType == OBJECT_TYPE_ITEM) ot = "UTI "; + else if (nObjectType == OBJECT_TYPE_TRIGGER) ot = "UTT "; + else if (nObjectType == OBJECT_TYPE_DOOR) ot = "UTD "; + else if (nObjectType == OBJECT_TYPE_WAYPOINT) ot = "UTW "; + else if (nObjectType == OBJECT_TYPE_PLACEABLE) ot = "UTP "; + else if (nObjectType == OBJECT_TYPE_STORE) ot = "UTM "; + else if (nObjectType == OBJECT_TYPE_ENCOUNTER) ot = "UTE "; + + if (ot == "") return JsonNull("invalid object type"); + + json ret = JsonObject(); + ret = JsonObjectSet(ret, "__data_type", JsonString(ot)); + return ret; +} + +json GffCreateArea(json jARE, json jGIT) +{ + json jCAF = JsonObject(); + jCAF = JsonObjectSet(jCAF, "__data_type", JsonString("CAF ")); + jCAF = GffAddStruct(jCAF, "ARE", jARE, 0); + jCAF = GffAddStruct(jCAF, "GIT", jGIT, 1); + return jCAF; +} + + +int GffGetObjectType(json jGff) +{ + json jDataType = JsonObjectGet(jGff, "__data_type"); + if (jDataType == JsonNull()) + return 0; + else + { + string sObjectType = JsonGetString(jDataType); + + if (sObjectType == "UTC ") return OBJECT_TYPE_CREATURE; + else if (sObjectType == "UTI ") return OBJECT_TYPE_ITEM; + else if (sObjectType == "UTT ") return OBJECT_TYPE_TRIGGER; + else if (sObjectType == "UTD ") return OBJECT_TYPE_DOOR; + else if (sObjectType == "UTW ") return OBJECT_TYPE_WAYPOINT; + else if (sObjectType == "UTP ") return OBJECT_TYPE_PLACEABLE; + else if (sObjectType == "UTM ") return OBJECT_TYPE_STORE; + else if (sObjectType == "UTE ") return OBJECT_TYPE_ENCOUNTER; + } + + return 0; +} + +int GffGetIsArea(json jGff) +{ + return JsonObjectGet(jGff, "__data_type") == JsonString("CAF "); +} + +int GffGetFieldExists(json jGff, string sLabel, string sType = "") +{ + json jFieldType = GffGetFieldType(jGff, sLabel); + return sType == "" ? jFieldType != JsonNull() : jFieldType == JsonString(sType); +} + + +json GffAddStruct(json jGff, string sLabel, json jStruct, int nType = -1) +{ + return GffAddField(jGff, sLabel, GFF_FIELD_TYPE_STRUCT, jStruct, nType); +} + +json GffAddList(json jGff, string sLabel, json jList) +{ + return GffAddField(jGff, sLabel, GFF_FIELD_TYPE_LIST, jList); +} + +json GffAddByte(json jGff, string sLabel, int v) +{ + return GffAddField(jGff, sLabel, GFF_FIELD_TYPE_BYTE, JsonInt(v)); +} + +json GffAddChar(json jGff, string sLabel, int v) +{ + return GffAddField(jGff, sLabel, GFF_FIELD_TYPE_CHAR, JsonInt(v)); +} + +json GffAddWord(json jGff, string sLabel, int v) +{ + return GffAddField(jGff, sLabel, GFF_FIELD_TYPE_WORD, JsonInt(v)); +} + +json GffAddShort(json jGff, string sLabel, int v) +{ + return GffAddField(jGff, sLabel, GFF_FIELD_TYPE_SHORT, JsonInt(v)); +} + +json GffAddDword(json jGff, string sLabel, int v) +{ + return GffAddField(jGff, sLabel, GFF_FIELD_TYPE_DWORD, JsonInt(v)); +} + +json GffAddInt(json jGff, string sLabel, int v) +{ + return GffAddField(jGff, sLabel, GFF_FIELD_TYPE_INT, JsonInt(v)); +} + +json GffAddDword64(json jGff, string sLabel, int v) +{ + return GffAddField(jGff, sLabel, GFF_FIELD_TYPE_DWORD64, JsonInt(v)); +} + +json GffAddInt64(json jGff, string sLabel, int v) +{ + return GffAddField(jGff, sLabel, GFF_FIELD_TYPE_INT64, JsonInt(v)); +} + +json GffAddFloat(json jGff, string sLabel, float v) +{ + return GffAddField(jGff, sLabel, GFF_FIELD_TYPE_FLOAT, JsonFloat(v)); +} + +json GffAddDouble(json jGff, string sLabel, float v) +{ + return GffAddField(jGff, sLabel, GFF_FIELD_TYPE_DOUBLE, JsonFloat(v)); +} + +json GffAddResRef(json jGff, string sLabel, string v) +{ + return GffAddField(jGff, sLabel, GFF_FIELD_TYPE_RESREF, JsonString(v)); +} + +json GffAddString(json jGff, string sLabel, string v) +{ + return GffAddField(jGff, sLabel, GFF_FIELD_TYPE_STRING, JsonString(v)); +} + +json GffAddLocString(json jGff, string sLabel, string v, int nStrRef = -1) +{ + return GffAddField(jGff, sLabel, GFF_FIELD_TYPE_LOC_STRING, GffLocString(v, nStrRef)); +} + + +json GffReplaceStruct(json jGff, string sLabel, json jStruct) +{ + return GffReplaceField(jGff, sLabel, GFF_FIELD_TYPE_STRUCT, jStruct); +} + +json GffReplaceList(json jGff, string sLabel, json jList) +{ + return GffReplaceField(jGff, sLabel, GFF_FIELD_TYPE_LIST, jList); +} + +json GffReplaceByte(json jGff, string sLabel, int v) +{ + return GffReplaceField(jGff, sLabel, GFF_FIELD_TYPE_BYTE, JsonInt(v)); +} + +json GffReplaceChar(json jGff, string sLabel, int v) +{ + return GffReplaceField(jGff, sLabel, GFF_FIELD_TYPE_CHAR, JsonInt(v)); +} + +json GffReplaceWord(json jGff, string sLabel, int v) +{ + return GffReplaceField(jGff, sLabel, GFF_FIELD_TYPE_WORD, JsonInt(v)); +} + +json GffReplaceShort(json jGff, string sLabel, int v) +{ + return GffReplaceField(jGff, sLabel, GFF_FIELD_TYPE_SHORT, JsonInt(v)); +} + +json GffReplaceDword(json jGff, string sLabel, int v) +{ + return GffReplaceField(jGff, sLabel, GFF_FIELD_TYPE_DWORD, JsonInt(v)); +} + +json GffReplaceInt(json jGff, string sLabel, int v) +{ + return GffReplaceField(jGff, sLabel, GFF_FIELD_TYPE_INT, JsonInt(v)); +} + +json GffReplaceDword64(json jGff, string sLabel, int v) +{ + return GffReplaceField(jGff, sLabel, GFF_FIELD_TYPE_DWORD64, JsonInt(v)); +} + +json GffReplaceInt64(json jGff, string sLabel, int v) +{ + return GffReplaceField(jGff, sLabel, GFF_FIELD_TYPE_INT64, JsonInt(v)); +} + +json GffReplaceFloat(json jGff, string sLabel, float v) +{ + return GffReplaceField(jGff, sLabel, GFF_FIELD_TYPE_FLOAT, JsonFloat(v)); +} + +json GffReplaceDouble(json jGff, string sLabel, float v) +{ + return GffReplaceField(jGff, sLabel, GFF_FIELD_TYPE_DOUBLE, JsonFloat(v)); +} + +json GffReplaceResRef(json jGff, string sLabel, string v) +{ + return GffReplaceField(jGff, sLabel, GFF_FIELD_TYPE_RESREF, JsonString(v)); +} + +json GffReplaceString(json jGff, string sLabel, string v) +{ + return GffReplaceField(jGff, sLabel, GFF_FIELD_TYPE_STRING, JsonString(v)); +} + +json GffReplaceLocString(json jGff, string sLabel, string v, int nStrRef = -1) +{ + return GffReplaceField(jGff, sLabel, GFF_FIELD_TYPE_LOC_STRING, GffLocString(v, nStrRef)); +} + + +json GffRemoveStruct(json jGff, string sLabel) +{ + return GffRemoveField(jGff, sLabel, GFF_FIELD_TYPE_STRUCT); +} + +json GffRemoveList(json jGff, string sLabel) +{ + return GffRemoveField(jGff, sLabel, GFF_FIELD_TYPE_LIST); +} + +json GffRemoveByte(json jGff, string sLabel) +{ + return GffRemoveField(jGff, sLabel, GFF_FIELD_TYPE_BYTE); +} + +json GffRemoveChar(json jGff, string sLabel) +{ + return GffRemoveField(jGff, sLabel, GFF_FIELD_TYPE_CHAR); +} + +json GffRemoveWord(json jGff, string sLabel) +{ + return GffRemoveField(jGff, sLabel, GFF_FIELD_TYPE_WORD); +} + +json GffRemoveShort(json jGff, string sLabel) +{ + return GffRemoveField(jGff, sLabel, GFF_FIELD_TYPE_SHORT); +} + +json GffRemoveDword(json jGff, string sLabel) +{ + return GffRemoveField(jGff, sLabel, GFF_FIELD_TYPE_DWORD); +} + +json GffRemoveInt(json jGff, string sLabel) +{ + return GffRemoveField(jGff, sLabel, GFF_FIELD_TYPE_INT); +} + +json GffRemoveDword64(json jGff, string sLabel) +{ + return GffRemoveField(jGff, sLabel, GFF_FIELD_TYPE_DWORD64); +} + +json GffRemoveInt64(json jGff, string sLabel) +{ + return GffRemoveField(jGff, sLabel, GFF_FIELD_TYPE_INT64); +} + +json GffRemoveFloat(json jGff, string sLabel) +{ + return GffRemoveField(jGff, sLabel, GFF_FIELD_TYPE_FLOAT); +} + +json GffRemoveDouble(json jGff, string sLabel) +{ + return GffRemoveField(jGff, sLabel, GFF_FIELD_TYPE_DOUBLE); +} + +json GffRemoveResRef(json jGff, string sLabel) +{ + return GffRemoveField(jGff, sLabel, GFF_FIELD_TYPE_RESREF); +} + +json GffRemoveString(json jGff, string sLabel) +{ + return GffRemoveField(jGff, sLabel, GFF_FIELD_TYPE_STRING); +} + +json GffRemoveLocString(json jGff, string sLabel) +{ + return GffRemoveField(jGff, sLabel, GFF_FIELD_TYPE_LOC_STRING); +} + + +json GffGetStruct(json jGff, string sLabel) +{ + return GffGetField(jGff, sLabel, GFF_FIELD_TYPE_STRUCT); +} + +json GffGetList(json jGff, string sLabel) +{ + return GffGetField(jGff, sLabel, GFF_FIELD_TYPE_LIST); +} + +json GffGetByte(json jGff, string sLabel) +{ + return GffGetField(jGff, sLabel, GFF_FIELD_TYPE_BYTE); +} + +json GffGetChar(json jGff, string sLabel) +{ + return GffGetField(jGff, sLabel, GFF_FIELD_TYPE_CHAR); +} + +json GffGetWord(json jGff, string sLabel) +{ + return GffGetField(jGff, sLabel, GFF_FIELD_TYPE_WORD); +} + +json GffGetShort(json jGff, string sLabel) +{ + return GffGetField(jGff, sLabel, GFF_FIELD_TYPE_SHORT); +} + +json GffGetDword(json jGff, string sLabel) +{ + return GffGetField(jGff, sLabel, GFF_FIELD_TYPE_DWORD); +} + +json GffGetInt(json jGff, string sLabel) +{ + return GffGetField(jGff, sLabel, GFF_FIELD_TYPE_INT); +} + +json GffGetDword64(json jGff, string sLabel) +{ + return GffGetField(jGff, sLabel, GFF_FIELD_TYPE_DWORD64); +} + +json GffGetInt64(json jGff, string sLabel) +{ + return GffGetField(jGff, sLabel, GFF_FIELD_TYPE_INT64); +} + +json GffGetFloat(json jGff, string sLabel) +{ + return GffGetField(jGff, sLabel, GFF_FIELD_TYPE_FLOAT); +} + +json GffGetDouble(json jGff, string sLabel) +{ + return GffGetField(jGff, sLabel, GFF_FIELD_TYPE_DOUBLE); +} + +json GffGetResRef(json jGff, string sLabel) +{ + return GffGetField(jGff, sLabel, GFF_FIELD_TYPE_RESREF); +} + +json GffGetString(json jGff, string sLabel) +{ + return GffGetField(jGff, sLabel, GFF_FIELD_TYPE_STRING); +} + +json GffGetLocString(json jGff, string sLabel) +{ + return GffGetField(jGff, sLabel, GFF_FIELD_TYPE_LOC_STRING); +} diff --git a/_module/nss/nw_inc_nui.nss b/_module/nss/nw_inc_nui.nss new file mode 100644 index 0000000..96fc3da --- /dev/null +++ b/_module/nss/nw_inc_nui.nss @@ -0,0 +1,1193 @@ +const int NUI_DIRECTION_HORIZONTAL = 0; +const int NUI_DIRECTION_VERTICAL = 1; + +const int NUI_MOUSE_BUTTON_LEFT = 0; +const int NUI_MOUSE_BUTTON_MIDDLE = 1; +const int NUI_MOUSE_BUTTON_RIGHT = 2; + +const int NUI_SCROLLBARS_NONE = 0; +const int NUI_SCROLLBARS_X = 1; +const int NUI_SCROLLBARS_Y = 2; +const int NUI_SCROLLBARS_BOTH = 3; +const int NUI_SCROLLBARS_AUTO = 4; + +const int NUI_ASPECT_FIT = 0; +const int NUI_ASPECT_FILL = 1; +const int NUI_ASPECT_FIT100 = 2; +const int NUI_ASPECT_EXACT = 3; +const int NUI_ASPECT_EXACTSCALED = 4; +const int NUI_ASPECT_STRETCH = 5; + +const int NUI_HALIGN_CENTER = 0; +const int NUI_HALIGN_LEFT = 1; +const int NUI_HALIGN_RIGHT = 2; + +const int NUI_VALIGN_MIDDLE = 0; +const int NUI_VALIGN_TOP = 1; +const int NUI_VALIGN_BOTTOM = 2; + +// ----------------------- +// Style + +const float NUI_STYLE_PRIMARY_WIDTH = 150.0; +const float NUI_STYLE_PRIMARY_HEIGHT = 50.0; + +const float NUI_STYLE_SECONDARY_WIDTH = 150.0; +const float NUI_STYLE_SECONDARY_HEIGHT = 35.0; + +const float NUI_STYLE_TERTIARY_WIDTH = 100.0; +const float NUI_STYLE_TERTIARY_HEIGHT = 30.0; + +const float NUI_STYLE_ROW_HEIGHT = 25.0; + +// ----------------------- +// Window + +// Special cases: +// * Set the window title to JsonBool(FALSE), Collapse to JsonBool(FALSE) and bClosable to FALSE +// to hide the title bar. +// Note: You MUST provide a way to close the window some other way, or the user will be stuck with it. +json // Window +NuiWindow( + json jRoot, // Layout-ish (NuiRow, NuiCol, NuiGroup) + json jTitle, // Bind:String + json jGeometry, // Bind:Rect Set x and/or y to -1.0 to center the window on that axis + // Set x and/or y to -2.0 to position the window's top left at the mouse cursor's position of that axis + // Set x and/or y to -3.0 to center the window on the mouse cursor's position of that axis + json jResizable, // Bind:Bool Set to JsonBool(TRUE) or JsonNull() to let user resize without binding. + json jCollapsed, // Bind:Bool Set to a static value JsonBool(FALSE) to disable collapsing. + // Set to JsonNull() to let user collapse without binding. + // For better UX, leave collapsing on. + json jClosable, // Bind:Bool You must provide a way to close the window if you set this to FALSE. + // For better UX, handle the window "closed" event. + json jTransparent, // Bind:Bool Do not render background + json jBorder, // Bind:Bool Do not render border + json jAcceptsInput = // Bind:Bool Set JsonBool(FALSE) to disable all input. + JSON_TRUE // All hover, clicks and keypresses will fall through. +); + +// ----------------------- +// Values + +// Create a dynamic bind. Unlike static values, these can change at runtime: +// NuiBind("mybindlabel"); +// NuiSetBind(.., "mybindlabel", JsonString("hi")); +// To create static values, just use the json types directly: +// JsonString("hi"); +json // Bind +NuiBind( + string sId +); + +// Tag the given element with a id. +// Only tagged elements will send events to the server. +json // Element +NuiId( + json jElem, // Element + string sId // String +); + +// A shim/helper that can be used to render or bind a strref where otherwise +// a string value would go. +json +NuiStrRef( + int nStrRef // STRREF +); + +// ----------------------- +// Layout + +// A column will auto-space all elements inside of it and advise the parent +// about it's desired size. +json // Layout +NuiCol( + json jList // Layout[] or Element[] +); + +// A row will auto-space all elements inside of it and advise the parent +// about it's desired size. +json // Layout +NuiRow( + json jList // Layout[] or Element[] +); + +// A group, usually with a border and some padding, holding a single element. Can scroll. +// Will not advise parent of size, so you need to let it fill a span (col/row) as if it was +// a element. +json // Layout +NuiGroup( + json jChild, // Layout or Element + int bBorder = TRUE, + int nScroll = NUI_SCROLLBARS_AUTO +); + +// Modifiers/Attributes: These are all static and cannot be bound, since the UI system +// cannot easily reflow once the layout is set up. You need to swap the layout if you +// want to change element geometry. + +json // Element +NuiWidth( + json jElem, // Element + float fWidth // Float: Element width in pixels (strength=required). +); + +json // Element +NuiHeight( + json jElem, // Element + float fHeight // Float: Height in pixels (strength=required). +); + +json // Element +NuiAspect( + json jElem, // Element + float fAspect // Float: Ratio of x/y. +); + +// Set a margin on the widget. The margin is the spacing outside of the widget. +json // Element +NuiMargin( + json jElem, // Element + float fMargin // Float +); + +// Set padding on the widget. The margin is the spacing inside of the widget. +json // Element +NuiPadding( + json jElem, // Element + float fPadding // Float +); + +// Disabled elements are non-interactive and greyed out. +json // Element +NuiEnabled( + json jElem, // Element + json jEnabler // Bind:Bool +); + +// Invisible elements do not render at all, but still take up layout space. +json // Element +NuiVisible( + json jElem, // Element + json jVisible // Bind:Bool +); + +// Tooltips show on mouse hover. +json // Element +NuiTooltip( + json jElem, // Element + json jTooltip // Bind:String +); + +// Tooltips for disabled elements show on mouse hover. +json // Element +NuiDisabledTooltip( + json jElem, // Element + json jTooltip // Bind:String +); + +// Encouraged elements have a breathing animated glow inside of it. +json // Element +NuiEncouraged( + json jElem, // Element + json jEncouraged // Bind:Bool +); + +// ----------------------- +// Props & Style + +json // Vec2 +NuiVec(float x, float y); + +json // Rect +NuiRect(float x, float y, float w, float h); + +json // Color +NuiColor(int r, int g, int b, int a = 255); + +// Style the foreground color of the widget. This is dependent on the widget +// in question and only supports solid/full colors right now (no texture skinning). +// For example, labels would style their text color; progress bars would style the bar. +json // Element +NuiStyleForegroundColor( + json jElem, // Element + json jColor // Bind:Color +); + +// ----------------------- +// Widgets + +// A special widget that just takes up layout space. +// If you add multiple spacers to a span, they will try to size equally. +// e.g.: [ ] will try to center the button. +json // Element +NuiSpacer(); + +// Create a label field. Labels are single-line stylable non-editable text fields. +json // Element +NuiLabel( + json jValue, // Bind:String + json jHAlign, // Bind:Int:NUI_HALIGN_* + json jVAlign // Bind:Int:NUI_VALIGN_* +); + +// Create a non-editable text field. Note: This text field internally implies a NuiGroup wrapped +// around it, which is providing the optional border and scrollbars. +json // Element +NuiText( + json jValue, // Bind:String + int bBorder = TRUE, // Bool + int nScroll = NUI_SCROLLBARS_AUTO // Int:NUI_SCROLLBARS_* +); + +// A clickable button with text as the label. +// Sends "click" events on click. +json // Element +NuiButton( + json jLabel // Bind:String +); + +// A clickable button with an image as the label. +// Sends "click" events on click. +json // Element +NuiButtonImage( + json jResRef // Bind:ResRef +); + +// A clickable button with text as the label. +// Same as the normal button, but this one is a toggle. +// Sends "click" events on click. +json // Element +NuiButtonSelect( + json jLabel, // Bind:String + json jValue // Bind:Bool +); + +// A checkbox with a label to the right of it. +json // Element +NuiCheck( + json jLabel, // Bind:String + json jBool // Bind:Bool +); + +// A image, with no border or padding. +json // Element +NuiImage( + json jResRef, // Bind:ResRef + json jAspect, // Bind:Int:NUI_ASPECT_* + json jHAlign, // Bind:Int:NUI_HALIGN_* + json jVAlign // Bind:Int:NUI_VALIGN_* +); + +// Optionally render only subregion of jImage. +// jRegion is a NuiRect (x, y, w, h) to indicate the render region inside the image. +json // NuiImage +NuiImageRegion( + json jImage, // NuiImage + json jRegion // Bind:NuiRect +); + +// A combobox/dropdown. +json // Element +NuiCombo( + json jElements, // Bind:ComboEntry[] + json jSelected // Bind:Int (index into jElements) +); + +json // ComboEntry +NuiComboEntry( + string sLabel, + int nValue +); + +// A floating-point slider. A good step size for normal-sized sliders is 0.01. +json // Element +NuiSliderFloat( + json jValue, // Bind:Float + json jMin, // Bind:Float + json jMax, // Bind:Float + json jStepSize // Bind:Float +); + +// A integer/discrete slider. +json // Element +NuiSlider( + json jValue, // Bind:Int + json jMin, // Bind:Int + json jMax, // Bind:Int + json jStepSize // Bind:Int +); + +// A progress bar. Progress is always from 0.0 to 1.0. +json // Element +NuiProgress( + json jValue // Bind:Float (0.0->1.0) +); + +// A editable text field. +json // Element +NuiTextEdit( + json jPlaceholder, // Bind:String + json jValue, // Bind:String + int nMaxLength, // UInt >= 1, <= 65535 + int bMultiline, // Bool + int bWordWrap = TRUE // Bool +); + +// Creates a list view of elements. +// jTemplate needs to be an array of NuiListTemplateCell instances. +// All binds referenced in jTemplate should be arrays of rRowCount size; +// e.g. when rendering a NuiLabel(), the bound label String should be an array of strings. +// You can pass in one of the template jRowCount into jSize as a convenience. The array +// size will be uses as the Int bind. +// jRowHeight defines the height of the rendered rows. +json // Element +NuiList( + json jTemplate, // NuiListTemplateCell[] (max: 16) + json jRowCount, // Bind:Int + float fRowHeight = NUI_STYLE_ROW_HEIGHT, + int bBorder = TRUE, + int nScroll = NUI_SCROLLBARS_Y // Note: Cannot be AUTO. +); + +json // NuiListTemplateCell +NuiListTemplateCell( + json jElem, // Element + float fWidth, // Float:0 = auto, >1 = pixel width + int bVariable // Bool:Cell can grow if space is available; otherwise static +); + +// A simple color picker, with no border or spacing. +json // Element +NuiColorPicker( + json jColor // Bind:Color +); + +// A list of options (radio buttons). Only one can be selected +// at a time. jValue is updated every time a different element is +// selected. The special value -1 means "nothing". +json // Element +NuiOptions( + int nDirection, // NUI_DIRECTION_* + json jElements, // JsonArray of string labels + json jValue // Bind:Int +); + +// A group of buttons. Only one can be selected at a time. jValue +// is updated every time a different button is selected. The special +// value -1 means "nothing". +json // Element +NuiToggles( + int nDirection, // NUI_DIRECTION_* + json jElements, // JsonArray of string labels + json jValue // Bind:Int +); + +const int NUI_CHART_TYPE_LINES = 0; +const int NUI_CHART_TYPE_COLUMN = 1; + +json // NuiChartSlot +NuiChartSlot( + int nType, // Int:NUI_CHART_TYPE_* + json jLegend, // Bind:String + json jColor, // Bind:NuiColor + json jData // Bind:Float[] +); + +// Renders a chart. +// Currently, min and max values are determined automatically and +// cannot be influenced. +json // Element +NuiChart( + json jSlots // NuiChartSlot[] +); + +// ----------------------- +// Draw Lists + +// Draw lists are raw painting primitives on top of widgets. +// They are anchored to the widget x/y coordinates, and are always +// painted in order of definition, without culling. You cannot bind +// the draw_list itself, but most parameters on individual draw_list +// entries can be bound. + +const int NUI_DRAW_LIST_ITEM_TYPE_POLYLINE = 0; +const int NUI_DRAW_LIST_ITEM_TYPE_CURVE = 1; +const int NUI_DRAW_LIST_ITEM_TYPE_CIRCLE = 2; +const int NUI_DRAW_LIST_ITEM_TYPE_ARC = 3; +const int NUI_DRAW_LIST_ITEM_TYPE_TEXT = 4; +const int NUI_DRAW_LIST_ITEM_TYPE_IMAGE = 5; +const int NUI_DRAW_LIST_ITEM_TYPE_LINE = 6; + +// You can order draw list items to be painted either before, or after the +// builtin render of the widget in question. This enables you to paint "behind" +// a widget. + +const int NUI_DRAW_LIST_ITEM_ORDER_BEFORE = -1; +const int NUI_DRAW_LIST_ITEM_ORDER_AFTER = 1; + +// Always render draw list item (default). +const int NUI_DRAW_LIST_ITEM_RENDER_ALWAYS = 0; +// Only render when NOT hovering. +const int NUI_DRAW_LIST_ITEM_RENDER_MOUSE_OFF = 1; +// Only render when mouse is hovering. +const int NUI_DRAW_LIST_ITEM_RENDER_MOUSE_HOVER = 2; +// Only render while LMB is held down. +const int NUI_DRAW_LIST_ITEM_RENDER_MOUSE_LEFT = 3; +// Only render while RMB is held down. +const int NUI_DRAW_LIST_ITEM_RENDER_MOUSE_RIGHT = 4; +// Only render while MMB is held down. +const int NUI_DRAW_LIST_ITEM_RENDER_MOUSE_MIDDLE = 5; + +json // DrawListItem +NuiDrawListPolyLine( + json jEnabled, // Bind:Bool + json jColor, // Bind:Color + json jFill, // Bind:Bool + json jLineThickness, // Bind:Float + json jPoints, // Bind:Float[] Always provide points in pairs + int nOrder = NUI_DRAW_LIST_ITEM_ORDER_AFTER, // Int:NUI_DRAW_LIST_ITEM_ORDER_* + int nRender = NUI_DRAW_LIST_ITEM_RENDER_ALWAYS // Int:NUI_DRAW_LIST_ITEM_RENDER_* +); + +json // DrawListItem +NuiDrawListCurve( + json jEnabled, // Bind:Bool + json jColor, // Bind:Color + json jLineThickness, // Bind:Float + json jA, // Bind:Vec2 + json jB, // Bind:Vec2 + json jCtrl0, // Bind:Vec2 + json jCtrl1, // Bind:Vec2 + int nOrder = NUI_DRAW_LIST_ITEM_ORDER_AFTER, // Int:NUI_DRAW_LIST_ITEM_ORDER_* + int nRender = NUI_DRAW_LIST_ITEM_RENDER_ALWAYS // Int:NUI_DRAW_LIST_ITEM_RENDER_* +); + +json // DrawListItem +NuiDrawListCircle( + json jEnabled, // Bind:Bool + json jColor, // Bind:Color + json jFill, // Bind:Bool + json jLineThickness, // Bind:Float + json jRect, // Bind:Rect + int nOrder = NUI_DRAW_LIST_ITEM_ORDER_AFTER, // Int:NUI_DRAW_LIST_ITEM_ORDER_* + int nRender = NUI_DRAW_LIST_ITEM_RENDER_ALWAYS // Int:NUI_DRAW_LIST_ITEM_RENDER_* +); + +json // DrawListItem +NuiDrawListArc( + json jEnabled, // Bind:Bool + json jColor, // Bind:Color + json jFill, // Bind:Bool + json jLineThickness, // Bind:Float + json jCenter, // Bind:Vec2 + json jRadius, // Bind:Float + json jAMin, // Bind:Float + json jAMax, // Bind:Float + int nOrder = NUI_DRAW_LIST_ITEM_ORDER_AFTER, // Int:NUI_DRAW_LIST_ITEM_ORDER_* + int nRender = NUI_DRAW_LIST_ITEM_RENDER_ALWAYS // Int:NUI_DRAW_LIST_ITEM_RENDER_* +); + +json // DrawListItem +NuiDrawListText( + json jEnabled, // Bind:Bool + json jColor, // Bind:Color + json jRect, // Bind:Rect + json jText, // Bind:String + int nOrder = NUI_DRAW_LIST_ITEM_ORDER_AFTER, // Int:NUI_DRAW_LIST_ITEM_ORDER_* + int nRender = NUI_DRAW_LIST_ITEM_RENDER_ALWAYS // Int:NUI_DRAW_LIST_ITEM_RENDER_* +); + +json // DrawListItem +NuiDrawListImage( + json jEnabled, // Bind:Bool + json jResRef, // Bind:ResRef + json jPos, // Bind:Rect + json jAspect, // Bind:Int:NUI_ASPECT_* + json jHAlign, // Bind:Int:NUI_HALIGN_* + json jVAlign, // Bind:Int:NUI_VALIGN_* + int nOrder = NUI_DRAW_LIST_ITEM_ORDER_AFTER, // Int:NUI_DRAW_LIST_ITEM_ORDER_* + int nRender = NUI_DRAW_LIST_ITEM_RENDER_ALWAYS // Int:NUI_DRAW_LIST_ITEM_RENDER_* +); + +json // DrawListItemImage +NuiDrawListImageRegion( + json jDrawListImage, // DrawListItemImage + json jRegion // Bind:NuiRect +); + +json // DrawListItem +NuiDrawListLine( + json jEnabled, // Bind:Bool + json jColor, // Bind:Color + json jLineThickness, // Bind:Float + json jA, // Bind:Vec2 + json jB, // Bind:Vec2 + int nOrder = NUI_DRAW_LIST_ITEM_ORDER_AFTER, // Int:NUI_DRAW_LIST_ITEM_ORDER_* + int nRender = NUI_DRAW_LIST_ITEM_RENDER_ALWAYS // Int:NUI_DRAW_LIST_ITEM_RENDER_* +); + +json // Element +NuiDrawList( + json jElem, // Element + json jScissor, // Bind:Bool Constrain painted elements to widget bounds. + json jList // DrawListItem[] +); + +// ----------------------- +// Implementation + +json +NuiWindow( + json jRoot, + json jTitle, + json jGeometry, + json jResizable, + json jCollapsed, + json jClosable, + json jTransparent, + json jBorder, + json jAcceptsInput +) +{ + json ret = JsonObject(); + // Currently hardcoded and here to catch backwards-incompatible data in the future. + ret = JsonObjectSet(ret, "version", JsonInt(1)); + ret = JsonObjectSet(ret, "title", jTitle); + ret = JsonObjectSet(ret, "root", jRoot); + ret = JsonObjectSet(ret, "geometry", jGeometry); + ret = JsonObjectSet(ret, "resizable", jResizable); + ret = JsonObjectSet(ret, "collapsed", jCollapsed); + ret = JsonObjectSet(ret, "closable", jClosable); + ret = JsonObjectSet(ret, "transparent", jTransparent); + ret = JsonObjectSet(ret, "border", jBorder); + ret = JsonObjectSet(ret, "accepts_input", jAcceptsInput); + return ret; +} + +json +NuiElement( + string sType, + json jLabel, + json jValue +) +{ + json ret = JsonObject(); + ret = JsonObjectSet(ret, "type", JsonString(sType)); + ret = JsonObjectSet(ret, "label", jLabel); + ret = JsonObjectSet(ret, "value", jValue); + return ret; +} + +json +NuiBind( + string sId +) +{ + return JsonObjectSet(JsonObject(), "bind", JsonString(sId)); +} + +json +NuiId( + json jElem, + string sId +) +{ + return JsonObjectSet(jElem, "id", JsonString(sId)); +} + +json +NuiStrRef( + int nStrRef +) +{ + json ret = JsonObject(); + ret = JsonObjectSet(ret, "strref", JsonInt(nStrRef)); + return ret; +} + +json +NuiCol( + json jList +) +{ + return JsonObjectSet(NuiElement("col", JsonNull(), JsonNull()), "children", jList); +} + +json +NuiRow( + json jList +) +{ + return JsonObjectSet(NuiElement("row", JsonNull(), JsonNull()), "children", jList); +} + +json +NuiGroup( + json jChild, + int bBorder = TRUE, + int nScroll = NUI_SCROLLBARS_AUTO +) +{ + json ret = NuiElement("group", JsonNull(), JsonNull()); + ret = JsonObjectSet(ret, "children", JsonArrayInsert(JsonArray(), jChild)); + ret = JsonObjectSet(ret, "border", JsonBool(bBorder)); + ret = JsonObjectSet(ret, "scrollbars", JsonInt(nScroll)); + return ret; +} + +json +NuiWidth(json jElem, float fWidth) +{ + return JsonObjectSet(jElem, "width", JsonFloat(fWidth)); +} + +json +NuiHeight(json jElem, float fHeight) +{ + return JsonObjectSet(jElem, "height", JsonFloat(fHeight)); +} + +json +NuiAspect(json jElem, float fAspect) +{ + return JsonObjectSet(jElem, "aspect", JsonFloat(fAspect)); +} + +json +NuiMargin( + json jElem, + float fMargin +) +{ + return JsonObjectSet(jElem, "margin", JsonFloat(fMargin)); +} + +json +NuiPadding( + json jElem, + float fPadding +) +{ + return JsonObjectSet(jElem, "padding", JsonFloat(fPadding)); +} + +json +NuiEnabled( + json jElem, + json jEnabler +) +{ + return JsonObjectSet(jElem, "enabled", jEnabler); +} + +json +NuiVisible( + json jElem, + json jVisible +) +{ + return JsonObjectSet(jElem, "visible", jVisible); +} + +json +NuiTooltip( + json jElem, + json jTooltip +) +{ + return JsonObjectSet(jElem, "tooltip", jTooltip); +} + +json +NuiDisabledTooltip( + json jElem, + json jTooltip +) +{ + return JsonObjectSet(jElem, "disabled_tooltip", jTooltip); +} + +json +NuiEncouraged( + json jElem, + json jEncouraged +) +{ + return JsonObjectSet(jElem, "encouraged", jEncouraged); +} + +json +NuiVec(float x, float y) +{ + json ret = JsonObject(); + ret = JsonObjectSet(ret, "x", JsonFloat(x)); + ret = JsonObjectSet(ret, "y", JsonFloat(y)); + return ret; +} + +json +NuiRect(float x, float y, float w, float h) +{ + json ret = JsonObject(); + ret = JsonObjectSet(ret, "x", JsonFloat(x)); + ret = JsonObjectSet(ret, "y", JsonFloat(y)); + ret = JsonObjectSet(ret, "w", JsonFloat(w)); + ret = JsonObjectSet(ret, "h", JsonFloat(h)); + return ret; +} + +json +NuiColor(int r, int g, int b, int a = 255) +{ + json ret = JsonObject(); + ret = JsonObjectSet(ret, "r", JsonInt(r)); + ret = JsonObjectSet(ret, "g", JsonInt(g)); + ret = JsonObjectSet(ret, "b", JsonInt(b)); + ret = JsonObjectSet(ret, "a", JsonInt(a)); + return ret; +} + +json +NuiStyleForegroundColor( + json jElem, + json jColor +) +{ + return JsonObjectSet(jElem, "foreground_color", jColor); +} + +json +NuiSpacer() +{ + return NuiElement("spacer", JsonNull(), JsonNull()); +} + +json +NuiLabel( + json jValue, + json jHAlign, + json jVAlign +) +{ + json ret = NuiElement("label", JsonNull(), jValue); + ret = JsonObjectSet(ret, "text_halign", jHAlign); + ret = JsonObjectSet(ret, "text_valign", jVAlign); + return ret; +} + +json +NuiText( + json jValue, + int bBorder = TRUE, + int nScroll = NUI_SCROLLBARS_AUTO +) +{ + json ret = NuiElement("text", JsonNull(), jValue); + ret = JsonObjectSet(ret, "border", JsonBool(bBorder)); + ret = JsonObjectSet(ret, "scrollbars", JsonInt(nScroll)); + return ret; +} + +json +NuiButton( + json jLabel +) +{ + return NuiElement("button", jLabel, JsonNull()); +} + +json +NuiButtonImage( + json jResRef +) +{ + return NuiElement("button_image", jResRef, JsonNull()); +} + +json +NuiButtonSelect( + json jLabel, + json jValue +) +{ + return NuiElement("button_select", jLabel, jValue); +} + +json +NuiCheck( + json jLabel, + json jBool +) +{ + return NuiElement("check", jLabel, jBool); +} + +json +NuiImage( + json jResRef, + json jAspect, + json jHAlign, + json jVAlign +) +{ + json img = NuiElement("image", JsonNull(), jResRef); + img = JsonObjectSet(img, "image_aspect", jAspect); + img = JsonObjectSet(img, "image_halign", jHAlign); + img = JsonObjectSet(img, "image_valign", jVAlign); + return img; +} + +json +NuiImageRegion( + json jImage, + json jRegion +) +{ + return JsonObjectSet(jImage, "image_region", jRegion); +} + +json +NuiCombo( + json jElements, + json jSelected +) +{ + return JsonObjectSet(NuiElement("combo", JsonNull(), jSelected), "elements", jElements); +} + +json +NuiComboEntry( + string sLabel, + int nValue +) +{ + return JsonArrayInsert(JsonArrayInsert(JsonArray(), JsonString(sLabel)), JsonInt(nValue)); +} + +json +NuiSliderFloat( + json jValue, + json jMin, + json jMax, + json jStepSize +) +{ + json ret = NuiElement("sliderf", JsonNull(), jValue); + ret = JsonObjectSet(ret, "min", jMin); + ret = JsonObjectSet(ret, "max", jMax); + ret = JsonObjectSet(ret, "step", jStepSize); + return ret; +} + +json +NuiSlider( + json jValue, + json jMin, + json jMax, + json jStepSize +) +{ + json ret = NuiElement("slider", JsonNull(), jValue); + ret = JsonObjectSet(ret, "min", jMin); + ret = JsonObjectSet(ret, "max", jMax); + ret = JsonObjectSet(ret, "step", jStepSize); + return ret; +} + +json +NuiProgress( + json jValue +) +{ + return NuiElement("progress", JsonNull(), jValue); +} + +json +NuiTextEdit( + json jPlaceholder, + json jValue, + int nMaxLength, + int bMultiline, + int bWordWrap = TRUE +) +{ + json ret = NuiElement("textedit", jPlaceholder, jValue); + ret = JsonObjectSet(ret, "max", JsonInt(nMaxLength)); + ret = JsonObjectSet(ret, "multiline", JsonBool(bMultiline)); + ret = JsonObjectSet(ret, "wordwrap", JsonBool(bWordWrap)); + return ret; +} + +json +NuiList( + json jTemplate, + json jRowCount, + float fRowHeight = NUI_STYLE_ROW_HEIGHT, + int bBorder = TRUE, + int nScroll = NUI_SCROLLBARS_Y +) +{ + json ret = NuiElement("list", JsonNull(), JsonNull()); + ret = JsonObjectSet(ret, "row_template", jTemplate); + ret = JsonObjectSet(ret, "row_count", jRowCount); + ret = JsonObjectSet(ret, "row_height", JsonFloat(fRowHeight)); + ret = JsonObjectSet(ret, "border", JsonBool(bBorder)); + ret = JsonObjectSet(ret, "scrollbars", JsonInt(nScroll)); + return ret; +} + +json +NuiListTemplateCell( + json jElem, + float fWidth, + int bVariable +) +{ + json ret = JsonArray(); + ret = JsonArrayInsert(ret, jElem); + ret = JsonArrayInsert(ret, JsonFloat(fWidth)); + ret = JsonArrayInsert(ret, JsonBool(bVariable)); + return ret; +} + +json +NuiColorPicker( + json jColor +) +{ + json ret = NuiElement("color_picker", JsonNull(), jColor); + return ret; +} + +json +NuiOptions( + int nDirection, + json jElements, + json jValue +) +{ + json ret = NuiElement("options", JsonNull(), jValue); + ret = JsonObjectSet(ret, "direction", JsonInt(nDirection)); + ret = JsonObjectSet(ret, "elements", jElements); + return ret; +} + +json +NuiToggles( + int nDirection, + json jElements, + json jValue +) +{ + json ret = NuiElement("tabbar", JsonNull(), jValue); + ret = JsonObjectSet(ret, "direction", JsonInt(nDirection)); + ret = JsonObjectSet(ret, "elements", jElements); + return ret; +} + +json +NuiChartSlot( + int nType, + json jLegend, + json jColor, + json jData +) +{ + json ret = JsonObject(); + ret = JsonObjectSet(ret, "type", JsonInt(nType)); + ret = JsonObjectSet(ret, "legend", jLegend); + ret = JsonObjectSet(ret, "color", jColor); + ret = JsonObjectSet(ret, "data", jData); + return ret; +} + +json +NuiChart( + json jSlots +) +{ + json ret = NuiElement("chart", JsonNull(), jSlots); + return ret; +} + +json +NuiDrawListItem( + int nType, + json jEnabled, + json jColor, + json jFill, + json jLineThickness, + int nOrder = NUI_DRAW_LIST_ITEM_ORDER_AFTER, + int nRender = NUI_DRAW_LIST_ITEM_RENDER_ALWAYS +) +{ + json ret = JsonObject(); + ret = JsonObjectSet(ret, "type", JsonInt(nType)); + ret = JsonObjectSet(ret, "enabled", jEnabled); + ret = JsonObjectSet(ret, "color", jColor); + ret = JsonObjectSet(ret, "fill", jFill); + ret = JsonObjectSet(ret, "line_thickness", jLineThickness); + ret = JsonObjectSet(ret, "order", JsonInt(nOrder)); + ret = JsonObjectSet(ret, "render", JsonInt(nRender)); + return ret; +} + +json +NuiDrawListPolyLine( + json jEnabled, + json jColor, + json jFill, + json jLineThickness, + json jPoints, + int nOrder = NUI_DRAW_LIST_ITEM_ORDER_AFTER, + int nRender = NUI_DRAW_LIST_ITEM_RENDER_ALWAYS +) +{ + json ret = NuiDrawListItem(NUI_DRAW_LIST_ITEM_TYPE_POLYLINE, jEnabled, jColor, jFill, jLineThickness, nOrder, nRender); + ret = JsonObjectSet(ret, "points", jPoints); + return ret; +} + +json +NuiDrawListCurve( + json jEnabled, + json jColor, + json jLineThickness, + json jA, + json jB, + json jCtrl0, + json jCtrl1, + int nOrder = NUI_DRAW_LIST_ITEM_ORDER_AFTER, + int nRender = NUI_DRAW_LIST_ITEM_RENDER_ALWAYS +) +{ + json ret = NuiDrawListItem(NUI_DRAW_LIST_ITEM_TYPE_CURVE, jEnabled, jColor, JsonBool(0), jLineThickness, nOrder, nRender); + ret = JsonObjectSet(ret, "a", jA); + ret = JsonObjectSet(ret, "b", jB); + ret = JsonObjectSet(ret, "ctrl0", jCtrl0); + ret = JsonObjectSet(ret, "ctrl1", jCtrl1); + return ret; +} + +json +NuiDrawListCircle( + json jEnabled, + json jColor, + json jFill, + json jLineThickness, + json jRect, + int nOrder = NUI_DRAW_LIST_ITEM_ORDER_AFTER, + int nRender = NUI_DRAW_LIST_ITEM_RENDER_ALWAYS +) +{ + json ret = NuiDrawListItem(NUI_DRAW_LIST_ITEM_TYPE_CIRCLE, jEnabled, jColor, jFill, jLineThickness, nOrder, nRender); + ret = JsonObjectSet(ret, "rect", jRect); + return ret; +} + +json +NuiDrawListArc( + json jEnabled, + json jColor, + json jFill, + json jLineThickness, + json jCenter, + json jRadius, + json jAMin, + json jAMax, + int nOrder = NUI_DRAW_LIST_ITEM_ORDER_AFTER, + int nRender = NUI_DRAW_LIST_ITEM_RENDER_ALWAYS +) +{ + json ret = NuiDrawListItem(NUI_DRAW_LIST_ITEM_TYPE_ARC, jEnabled, jColor, jFill, jLineThickness, nOrder, nRender); + ret = JsonObjectSet(ret, "c", jCenter); + ret = JsonObjectSet(ret, "radius", jRadius); + ret = JsonObjectSet(ret, "amin", jAMin); + ret = JsonObjectSet(ret, "amax", jAMax); + return ret; +} + +json +NuiDrawListText( + json jEnabled, + json jColor, + json jRect, + json jText, + int nOrder = NUI_DRAW_LIST_ITEM_ORDER_AFTER, + int nRender = NUI_DRAW_LIST_ITEM_RENDER_ALWAYS +) +{ + json ret = NuiDrawListItem(NUI_DRAW_LIST_ITEM_TYPE_TEXT, jEnabled, jColor, JsonNull(), JsonNull(), nOrder, nRender); + ret = JsonObjectSet(ret, "rect", jRect); + ret = JsonObjectSet(ret, "text", jText); + return ret; +} + +json +NuiDrawListImage( + json jEnabled, + json jResRef, + json jRect, + json jAspect, + json jHAlign, + json jVAlign, + int nOrder = NUI_DRAW_LIST_ITEM_ORDER_AFTER, + int nRender = NUI_DRAW_LIST_ITEM_RENDER_ALWAYS +) +{ + json ret = NuiDrawListItem(NUI_DRAW_LIST_ITEM_TYPE_IMAGE, jEnabled, JsonNull(), JsonNull(), JsonNull(), nOrder, nRender); + ret = JsonObjectSet(ret, "image", jResRef); + ret = JsonObjectSet(ret, "rect", jRect); + ret = JsonObjectSet(ret, "image_aspect", jAspect); + ret = JsonObjectSet(ret, "image_halign", jHAlign); + ret = JsonObjectSet(ret, "image_valign", jVAlign); + return ret; +} + +json +NuiDrawListImageRegion( + json jDrawListImage, + json jRegion +) +{ + return JsonObjectSet(jDrawListImage, "image_region", jRegion); +} + +json +NuiDrawListLine( + json jEnabled, + json jColor, + json jLineThickness, + json jA, + json jB, + int nOrder = NUI_DRAW_LIST_ITEM_ORDER_AFTER, + int nRender = NUI_DRAW_LIST_ITEM_RENDER_ALWAYS +) +{ + json ret = NuiDrawListItem(NUI_DRAW_LIST_ITEM_TYPE_LINE, jEnabled, jColor, JsonNull(), jLineThickness, nOrder, nRender); + ret = JsonObjectSet(ret, "a", jA); + ret = JsonObjectSet(ret, "b", jB); + return ret; +} + +json +NuiDrawList( + json jElem, + json jScissor, + json jList +) +{ + json ret = JsonObjectSet(jElem, "draw_list", jList); + ret = JsonObjectSet(ret, "draw_list_scissor", jScissor); + return ret; +} + +// json +// NuiCanvas( +// json jList +// ) +// { +// json ret = NuiElement("canvas", JsonNull(), jList); +// return ret; +// } +