Skip to content

Commit

Permalink
Magic menu appears to be working
Browse files Browse the repository at this point in the history
  • Loading branch information
Odie committed Sep 22, 2018
1 parent 7b8a3d9 commit 9a0692b
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 40 deletions.
110 changes: 70 additions & 40 deletions src/ItemMenus/MagicMenu.as
Original file line number Diff line number Diff line change
Expand Up @@ -10,64 +10,85 @@ import skyui.props.PropertyDataExtender;

import skyui.defines.Input;
import skyui.defines.Inventory;
import skyui.util.Debug;


class MagicMenu extends ItemMenu
{
#include "../version.as"

/* PRIVATE VARIABLES */

private var _hideButtonFlag: Number = 0;
private var _bMenuClosing: Boolean = false;
private var _bSwitchMenus: Boolean = false;

private var _categoryListIconArt: Array;


/* PROPERTIES */

public var hideButtonFlag: Number;


/* INITIALIZATION */

public function MagicMenu()
{
super();

_categoryListIconArt = ["cat_favorites", "mag_all", "mag_alteration", "mag_illusion",
"mag_destruction", "mag_conjuration", "mag_restoration", "mag_shouts",
"mag_powers", "mag_activeeffects"];
}



function OnShow() {
_bMenuClosing = false;
//iLastItemType = InventoryDefines.ICT_NONE;
//bottomBar.iLastItemType = Inventory.ICT_NONE;
/* ResetItemCard({type:Inventory.ICT_SPELL_DEFAULT}); */
/* itemCard.bFadedIn = false; */
/* itemCard._visible = false; */
//inventoryLists.showPanel(false);
if(!bFadedIn) {
this.ToggleMenuFade();
}
/* bottomBar.GoToDefaultFrame(); */
/* bottomBar.HideButtons(); */
}

/* PUBLIC FUNCTIONS */

public function InitExtensions(): Void
{
super.InitExtensions();

GameDelegate.addCallBack("DragonSoulSpent", this, "DragonSoulSpent");
GameDelegate.addCallBack("AttemptEquip", this , "AttemptEquip");

bottomBar.updatePerItemInfo({type:Inventory.ICT_SPELL_DEFAULT});

// Initialize menu-specific list components
var categoryList: CategoryList = inventoryLists.categoryList;
categoryList.iconArt = _categoryListIconArt;

// SkyrimVR moves some variables from the "Interface" section to the "VRUI" section.
// Originally, SkyUI patched these positions in papyrus scripts to line up with the new UI.
// It does seem to make sense for this kind of patching to be done from the UI itself though.
var itemPosXSettingName = "fMagic3DItemPosX:VRUI";
skse.SetINISetting(itemPosXSettingName, skse.GetINISetting(itemPosXSettingName) - 37);
}

// @override ItemMenu
public function setConfig(a_config: Object): Void
{
super.setConfig(a_config);

var itemList: TabularList = inventoryLists.itemList;
itemList.addDataProcessor(new MagicDataSetter(a_config["Appearance"]));
itemList.addDataProcessor(new MagicIconSetter(a_config["Appearance"]));
itemList.addDataProcessor(new PropertyDataExtender(a_config["Appearance"], a_config["Properties"], "magicProperties", "magicIcons", "magicCompoundProperties"));

var layout: ListLayout = ListLayoutManager.createLayout(a_config["ListLayout"], "MagicListLayout");
itemList.layout = layout;

Expand All @@ -81,12 +102,12 @@ class MagicMenu extends ItemMenu
{
if (!bFadedIn)
return true;

var nextClip = pathToFocus.shift();

if (nextClip.handleInput(details, pathToFocus))
return true;

if (GlobalFunc.IsKeyPressed(details)) {
if (details.navEquivalent == NavigationCode.TAB || details.navEquivalent == NavigationCode.SHIFT_TAB ) {
startMenuFade();
Expand All @@ -106,17 +127,17 @@ class MagicMenu extends ItemMenu
itemCard.itemInfo.soulSpent = true;
updateBottomBar();
}

// @API
public function AttemptEquip(a_slot: Number): Void
{
if (shouldProcessItemsListInput(true) && confirmSelectedEntry())
GameDelegate.call("ItemSelect",[a_slot]);
}


/* PRIVATE FUNCTIONS */

// @override ItemMenu
private function onItemSelect(event: Object): Void
{
Expand All @@ -128,7 +149,7 @@ class MagicMenu extends ItemMenu
GameDelegate.call("ShowShoutFail",[]);
}
}

// @override ItemMenu
private function onExitMenuRectClick(): Void
{
Expand All @@ -152,7 +173,7 @@ class MagicMenu extends ItemMenu
private function onShowItemsList(event: Object): Void
{
super.onShowItemsList(event);

if (event.index != -1)
updateBottomBar(true);
}
Expand All @@ -161,7 +182,7 @@ class MagicMenu extends ItemMenu
private function onItemHighlightChange(event: Object)
{
super.onItemHighlightChange(event);

if (event.index != -1)
updateBottomBar(true);
}
Expand All @@ -170,12 +191,12 @@ class MagicMenu extends ItemMenu
private function onHideItemsList(event: Object): Void
{
super.onHideItemsList(event);

bottomBar.updatePerItemInfo({type:Inventory.ICT_SPELL_DEFAULT});

updateBottomBar(false);
}

private function openInventoryMenu(a_bFade: Boolean): Void
{
if (a_bFade) {
Expand All @@ -188,23 +209,32 @@ class MagicMenu extends ItemMenu
skse.OpenMenu("InventoryMenu");
}
}

// @override ItemMenu
private function updateBottomBar(a_bSelected: Boolean): Void
{
navPanel.clearButtons();


var activateControls = skyui.util.Input.pickControls(_platform,
{PCArt:"E",XBoxArt:"360_A",PS3Art:"PS3_A",ViveArt:"trigger",MoveArt:"PS3_MOVE",OculusArt:"trigger",WindowsMRArt:"trigger"});
var exitControls = skyui.util.Input.pickControls(_platform,
{PCArt:"Tab",XBoxArt:"360_B",PS3Art:"PS3_B",ViveArt:"grip",MoveArt:"PS3_B",OculusArt:"grab",WindowsMRArt:"grab"});
var favoriteControls = skyui.util.Input.pickControls(_platform,
{PCArt:"F",XBoxArt:"360_Y",PS3Art:"PS3_Y",ViveArt:"radial_Either_Right",MoveArt:"PS3_Y",OculusArt:"OCC_B",WindowsMRArt:"radial_Either_Right"});
var unlockControls = skyui.util.Input.pickControls(_platform,
{PCArt:"R",XBoxArt:"360_X",PS3Art:"PS3_X",ViveArt:"radial_Either_Left",MoveArt:"PS3_X",OculusArt:"OCC_Y",WindowsMRArt:"radial_Either_Left"});

if (a_bSelected && (inventoryLists.itemList.selectedEntry.filterFlag & Inventory.FILTERFLAG_MAGIC_ACTIVEEFFECTS) == 0) {
navPanel.addButton({text: "$Equip", controls: Input.Equip});
navPanel.addButton({text: "$Equip", controls: activateControls});

if (inventoryLists.itemList.selectedEntry.filterFlag & inventoryLists.categoryList.entryList[0].flag != 0)
navPanel.addButton({text: "$Unfavorite", controls: Input.YButton});
navPanel.addButton({text: "$Unfavorite", controls: favoriteControls});
else
navPanel.addButton({text: "$Favorite", controls: Input.YButton});
navPanel.addButton({text: "$Favorite", controls: favoriteControls});

if (itemCard.itemInfo.showUnlocked)
navPanel.addButton({text: "$Unlock", controls: Input.XButton});
navPanel.addButton({text: "$Unlock", controls: unlockControls});

} else {
navPanel.addButton({text: "$Exit", controls: _cancelControls});
navPanel.addButton({text: "$Search", controls: _searchControls});
Expand All @@ -214,15 +244,15 @@ class MagicMenu extends ItemMenu
}
navPanel.addButton({text: "$Inventory", controls: _switchControls});
}

navPanel.updateButtons(true);
}

private function startMenuFade(): Void
{
inventoryLists.hidePanel();
//inventoryLists.hidePanel();
ToggleMenuFade();
saveIndices();
_bMenuClosing = true;
}
}
}
Binary file modified src/ItemMenus/magicmenu.fla
Binary file not shown.

0 comments on commit 9a0692b

Please sign in to comment.