The-Frozen-North / tfn-module

A persistent world set around Neverwinter and the Wailing Death, with content from HotU and NWN2
https://github.com/b5635/the-frozen-north/wiki
GNU Affero General Public License v3.0
31 stars 24 forks source link

Add special abilities menu for polymorph shapes #681

Open b5635 opened 1 year ago

b5635 commented 1 year ago

When polymorphing it can be annoying to cast spells from radial. TomRotfl has kindly donated this script snippet that we can use as a base line:

`void CreateAndStoreSpecialAbilitiesMenu() { //declare the jsons json jRow = JsonArray(); json jCol0 = JsonArray();
json jCol1 = JsonArray(); json jCol2 = JsonArray(); json jCol3 = JsonArray(); json jCol4 = JsonArray();

//add zero button ( can be the unpolymorph, or main ability )
jCol0 = JsonArrayInsert(jCol0, NuiTooltip(NuiWidth(NuiHeight(NuiId(NuiButtonImage(NuiBind("spe_abil_img_0")),
                                                                    "spe_abil_funct_0"), 40.0), 40.0),
                                                                    NuiBind("spe_abil_name_0")));

//add first button
jCol1 = JsonArrayInsert(jCol1, NuiTooltip(NuiWidth(NuiHeight(NuiId(NuiButtonImage(NuiBind("spe_abil_img_1")),
                                                                    "spe_abil_funct_1"), 40.0), 40.0),
                                                                    NuiBind("spe_abil_name_1"))); 

//add second button
jCol2 = JsonArrayInsert(jCol2, NuiTooltip(NuiWidth(NuiHeight(NuiId(NuiButtonImage(NuiBind("spe_abil_img_2")),
                                                                    "spe_abil_funct_2"), 40.0), 40.0),
                                                                    NuiBind("spe_abil_name_2"))); 

//add third button
jCol3 = JsonArrayInsert(jCol3, NuiTooltip(NuiWidth(NuiHeight(NuiId(NuiButtonImage(NuiBind("spe_abil_img_3")),
                                                                    "spe_abil_funct_3"), 40.0), 40.0),
                                                                    NuiBind("spe_abil_name_3"))); 

//add examine button
jCol4 = JsonArrayInsert(jCol4, NuiTooltip(NuiWidth(NuiHeight(NuiId(NuiButtonImage(JsonString("ir_search")),
                                                                    "spe_abil_funct_4"), 30.0), 30.0),
                                                                    JsonString("Info")));                                                                       

//make them columns
jCol0 = NuiCol(jCol0);
jCol1 = NuiCol(jCol1);
jCol2 = NuiCol(jCol2);
jCol3 = NuiCol(jCol3);
jCol4 = NuiCol(jCol4);
//add enabled bind
jCol1 = NuiEnabled(jCol1, NuiBind("spe_abil_enabled_1")); 
jCol2 = NuiEnabled(jCol2, NuiBind("spe_abil_enabled_2"));
jCol3 = NuiEnabled(jCol3, NuiBind("spe_abil_enabled_3"));       

//add al to jRow
jRow = JsonArrayInsert(jRow, jCol0);                                                                  

//add spacer
jRow = JsonArrayInsert(jRow, NuiSpacer());

//add other abilities
jRow = JsonArrayInsert(jRow, jCol1); 
jRow = JsonArrayInsert(jRow, jCol2); 
jRow = JsonArrayInsert(jRow, jCol3); 
jRow = JsonArrayInsert(jRow, jCol4);                                                                          

//make jRow a column
jRow = NuiRow(jRow);

//build the nui window
json jNui = NuiWindow
(
    jRow,
    JsonString(""),//NuiBind("spe_abil_title"),
    NuiBind(NUI_WINDOW_GEOMETRY_TAG),          //NuiRect(1485.0f, 905.0f, 200.0, 50.0),
    JsonBool(FALSE),                           // can be resized?
    JsonBool(FALSE),                           // collapsed or not? null = we don't care let the user decide
    JsonBool(FALSE),                           // can it be closed?
    JsonBool(TRUE),                            // is transparent?
    JsonBool(FALSE)                            // has a border?
);

//store the JSON on module
SetLocalJson(oMod, "NUI_SPECIAL_ABILITIES_TEMPLATE", jNui);                                                                                                                                                                                                                 

}`