void OpenItemList()
    {
        //sets a string called absPath using the return from OpenFilePanel
        string absPath = EditorUtility.OpenFilePanel("Select Inventory Item List", "", "");

        //Checks to see if the path to the Inventory is the same as the path to the game data folder
        //Application.dataPath is the path to the game data folder
        if (absPath.StartsWith(Application.dataPath))
        {
            //sets the string relPath to be path to the Inventory
            string relPath = absPath.Substring(Application.dataPath.Length - "Assets".Length);
            //sets inventoryItemList as the InventoryItemList at the end of the path
            inventoryItemList = AssetDatabase.LoadAssetAtPath(relPath, typeof(InventoryItemList)) as InventoryItemList;
            //If there is no InventoryItemList there
            if (inventoryItemList.itemList == null)
            {
                //Create a new InventoryItemList
                inventoryItemList.itemList = new List <InventoryItem>();
            }
            //If there is an inventoryItemList
            if (inventoryItemList)
            {
                //Set ObjectPath to relPath
                EditorPrefs.SetString("ObjectPath", relPath);
            }
        }
    }
Example #2
0
 void OnEnable()
 {
     if (EditorPrefs.HasKey("ObjectPath"))
     {
         string objectPath = EditorPrefs.GetString("ObjectPath");
         inventoryItemList = AssetDatabase.LoadAssetAtPath(objectPath, typeof(InventoryItemList)) as InventoryItemList;
     }
 }
    public static InventoryItemList Create()
    {
        InventoryItemList asset = ScriptableObject.CreateInstance <InventoryItemList>();

        AssetDatabase.CreateAsset(asset, "Assets/InventoryItemList.asset");
        AssetDatabase.SaveAssets();
        return(asset);
    }
 void OnEnable()
 {
     //Loading previously saved Item List
     if (EditorPrefs.HasKey("ObjectPath"))
     {
         string objectPath = EditorPrefs.GetString("ObjectPath");
         inventoryItemList = AssetDatabase.LoadAssetAtPath <InventoryItemList>(objectPath);
     }
 }
Example #5
0
 void OnEnable()
 {
     Debug.Log ("InventoryItemEditor.OnEnable() called!");
     if(EditorPrefs.HasKey("ObjectPath")){
         string objectPath = EditorPrefs.GetString("ObjectPath");
         inventoryItemList = AssetDatabase.LoadAssetAtPath(objectPath, typeof(InventoryItemList)) as InventoryItemList;
         Debug.Log ("EditorPrefs.ObjectPath: "+EditorPrefs.GetString("ObjectPath"));
     }
 }
Example #6
0
 public virtual void AddItemActions(InventoryItemList inventory, Creature player, MenuTextSelection selection)
 {
     selection.Add(new ActAction("Throw Away", "Drop the item on the ground.", () =>
     {
         MoveTo(player.Tile);
         selection.Close();
         inventory.Reset();
     }));
 }
    public static InventoryItemList Create()
    {
        InventoryItemList asset = ScriptableObject.CreateInstance <InventoryItemList>();

        asset.itemList = new System.Collections.Generic.List <InventoryItem>();

        AssetDatabase.CreateAsset(asset, "Assets/InventoryItemList.asset");
        AssetDatabase.SaveAssets();
        return(asset);
    }
 void CreateNewItemList()
 {
     viewIndex         = 1;
     inventoryItemList = CreateInventoryItemList.Create();
     if (inventoryItemList)
     {
         inventoryItemList.itemList = new List <InventoryItem>();
         string relPath = AssetDatabase.GetAssetPath(inventoryItemList);
         EditorPrefs.SetString("ObjectPath", relPath);
     }
 }
Example #9
0
 void CreateNewItemList()
 {
     // There is no overwrite protection here!
     // There is No "Are you sure you want to overwrite your existing object?" if it exists.
     // This should probably get a string from the user to create a new name and pass it ...
     viewIndex         = 1;
     inventoryItemList = CreateInventoryItemList.Create();
     if (inventoryItemList)
     {
         inventoryItemList.itemList = new List <InventoryItem>();
         string relPath = AssetDatabase.GetAssetPath(inventoryItemList);
         EditorPrefs.SetString("ObjectPath", relPath);
     }
 }
Example #10
0
    void CreateNewItemList()
    {
        //There is no overwrite protection here!
        //There is No "Are you sure you want to overwrite your exsisting object?" if it exists..
        //This should probably get a string from the uset to create a new name and pass it...

        viewIndex = 1;
        inventoryItemList = CreateInventoryItemList.Create();
        if(inventoryItemList){
            string relPath = AssetDatabase.GetAssetPath(inventoryItemList);
            Debug.Log (relPath);
            EditorPrefs.SetString("ObjectPath", relPath);
        }
    }
 void  OnEnable()
 {
     //Finding the object path
     //Does the Editor have the key "ObjectPath"
     if (EditorPrefs.HasKey("ObjectPath"))
     {
         //Sets a string called objectPath as the return from EditorPrefs.GetString
         //which should be the same as the key "ObjectPath"
         string objectPath = EditorPrefs.GetString("ObjectPath");
         //Returns the first asset object of type InventoryItemList at given path objectPath
         //sets as inventoryItemList
         inventoryItemList = AssetDatabase.LoadAssetAtPath(objectPath, typeof(InventoryItemList)) as InventoryItemList;
     }
 }
Example #12
0
 public static InventoryItemList ParseInventoryItems(string data)
 {
     data = data.Replace("\x08", "b");
     InventoryItemList inventoryItemList = new InventoryItemList();
     MatchCollection matches = _regexInventoryItems.Matches(data);
     foreach (Match matchItem in matches)
     {
         InventoryItem inventoryItem = ParseInventoryItem(matchItem);
         if (inventoryItem != null)
         {
             inventoryItemList.Add(inventoryItem);
         }
     }
     return inventoryItemList;
 }
        public static bool DoJoin(NetworkClient networkClient, GameClient client)
        {
            Dictionary<string, InventoryItemList> items = new Dictionary<string, InventoryItemList>();

            foreach (InventoryItem inventoryItem in client.InventoryItems)
            {
                //Get the item ident
                string ident = inventoryItem.Ident;
                InventoryItemList inventoryItemsList;

                //Get items list for the item
                if (items.ContainsKey(ident))
                {
                    inventoryItemsList = items[ident];
                }
                else
                {
                    items.Add(ident, inventoryItemsList = new InventoryItemList());
                }

                //Add the item to items list
                inventoryItemsList.Add(inventoryItem);
            }

            //Do join items
            foreach (string ident in items.Keys)
            {
                InventoryItemList inventoryItemsList = items[ident];
                int itemsCount = inventoryItemsList.Count;
                if (itemsCount > 1)
                {
                    InventoryItem item2 = inventoryItemsList[0];
                    for (int i = 1; i < itemsCount; i++)
                    {
                        InventoryItem item1 = inventoryItemsList[i];
                        string joinInventory = Packet.BuildPacket(FromClient.JOIN_INVENTORY,
                            item1.ID, item2.ID);
                        networkClient.SendData(joinInventory);
                        item2.Count += item1.Count;
                        client.InventoryItems.Remove(item1);
                    }
                }
            }

            return true;
        }
Example #14
0
        public RCModelListView(bool isDataEditable)
        {
            InitializeComponent();

            vm             = new RCModelViewModel();
            BindingContext = vm;

            // Load the Activity Log report into ListView class.
            vm.LoadRCModels();

            _isDataEditable      = isDataEditable;
            App.selectedItemName = null;
            App.selectedItemID   = 0;
            //
            if (_isDataEditable)
            {
                ToolbarItem tbi = null;
                if (Device.OS == TargetPlatform.iOS)
                {
                    tbi = new ToolbarItem("+", null, () =>
                    {
                        var RCItem = new InventoryItemList();
                        // create a new details view with the item
                        var view = new RCInventoryDetailsView(RCItem, App.ItemCategory_MODEL);
                        //// tell the navigator to show the new view
                        Navigation.PushAsync(view);
                    }, 0, 0);
                }
                if (Device.OS == TargetPlatform.Android)
                { // BUG: Android doesn't support the icon being null
                    tbi = new ToolbarItem("+", "plus", () =>
                    {
                        var RCItem = new InventoryItemList();
                        // create a new details view with the item
                        var view = new RCInventoryDetailsView(RCItem, App.ItemCategory_MODEL);
                        //// tell the navigator to show the new view
                        Navigation.PushAsync(view);
                    }, 0, 0);
                }
                //
                ToolbarItems.Add(tbi);
            }
            //
            lblNoOfModels.Text = "No. of Models: " + vm.RCModelLV.Count.ToString();
        }
Example #15
0
    void OpenItemList()
    {
        string absPath = EditorUtility.OpenFilePanel("Select Inventory Item List", "", "");

        if (absPath.StartsWith(Application.dataPath))
        {
            string relPath = absPath.Substring(Application.dataPath.Length - "Assets".Length);
            inventoryItemList = AssetDatabase.LoadAssetAtPath(relPath, typeof(InventoryItemList)) as InventoryItemList;
            if (inventoryItemList.itemList == null)
            {
                inventoryItemList.itemList = new List <InventoryItem>();
            }
            if (inventoryItemList)
            {
                EditorPrefs.SetString("ObjectPath", relPath);
            }
        }
    }
        private InventoryItem TransferToInventoryItemRec(InventoryItemList IIList)
        {
            InventoryItem IIRec = new InventoryItem();

            //
            IIRec.ID            = IIList.ID;
            IIRec.ItemCategory  = IIList.ItemCategory;
            IIRec.ItemName      = IIList.ItemName;
            IIRec.ItemNumber    = IIList.ItemNumber;
            IIRec.ItemType      = IIList.ItemType;
            IIRec.Manufacturer  = IIList.Manufacturer;
            IIRec.Notes         = IIList.Notes;
            IIRec.PurchaseDate  = IIList.PurchaseDate;
            IIRec.PurchasePrice = IIList.PurchasePrice;
            IIRec.RetailPrice   = IIList.RetailPrice;
            //
            return(IIRec);
        }
    private void OnEnable()
    {
        //Target the selected itemList in Unity's project view
        inventoryItemList = (InventoryItemList)target;

        if (inventoryItemList.itemList == null)
        {
            inventoryItemList.itemList = new Item[0];
        }

        if (itemsEditors == null)
        {
            CreateEditors();
        }

        //Cache the itemList properties
        itemListNameProperty        = serializedObject.FindProperty(itemListNamePropName);
        itemListDescriptionProperty = serializedObject.FindProperty(itemListDescriptionPropName);
    }
    public static InventoryItemList CreateInventoryItemList()
    {
        InventoryItemList asset = ScriptableObject.CreateInstance <InventoryItemList>();

        if (!Directory.Exists(BASE_PATH))
        {
            Directory.CreateDirectory(BASE_PATH);
        }

        if (AssetDatabase.LoadAssetAtPath <InventoryItemList>(BASE_PATH + AKAGF_PATHS.NEW_INVENTORY_ITEM_LIST_BASE_NAME) == null)
        {
            AssetDatabase.CreateAsset(asset, BASE_PATH + AKAGF_PATHS.NEW_INVENTORY_ITEM_LIST_BASE_NAME);
            AssetDatabase.SaveAssets();
            return(asset);
        }

        Debug.Log("There is already an InventoryItemList.asset, change the name of that ItemList first, then create another one.");
        return(null);
    }
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        EditorGUI.BeginChangeCheck();

        InventoryItemList itemsList = (InventoryItemList)target;

        if (GUILayout.Button("Open in Editor"))
        {
            InventoryItemEditor inventoryItemEditor = (InventoryItemEditor)EditorWindow.GetWindow(typeof(InventoryItemEditor));
            inventoryItemEditor.inventoryItemList = itemsList;
        }
        EditorGUILayout.PropertyField(items, new GUIContent("Items"), true);

        serializedObject.ApplyModifiedProperties();
        if (GUI.changed)
        {
            EditorUtility.SetDirty(itemsList);
        }
    }
    void CreateNewItemList()
    {
        // There is no overwrite protection here!
        // There is No "Are you sure you want to overwrite your existing object?" if it exists.
        // This should probably get a string from the user to create a new name and pass it ...

        //Chooses the inventory and sets the viewIndex value
        viewIndex = 1;
        //Creates a new inventoryItemList Scriptable Object
        inventoryItemList = CreateInventoryItemList.Create();
        //if there is an inventoryItemList
        if (inventoryItemList)
        {
            //set the inventoryItemList as a new List of InventoryItem Scriptable Objects
            inventoryItemList.itemList = new List <InventoryItem>();
            //sets a string called relPath using GetAssetPath
            string relPath = AssetDatabase.GetAssetPath(inventoryItemList);
            //Sets the string ObjectPath to be the same as the string relPath
            //This sets the path to the Inventory so that it can be found again
            EditorPrefs.SetString("ObjectPath", relPath);
        }
    }
Example #21
0
        public void LoadRCModels()
        {
            //AddActivityLogRecs();
            RCModelLV.Clear();

            IEnumerable <InventoryItem> RCModels = App.Database.GetAllItems(App.ItemCategory_MODEL);

            foreach (var RCModel in RCModels)
            {
                InventoryItemList MList = new InventoryItemList();
                MList.ID           = RCModel.ID;
                MList.ItemCategory = RCModel.ItemCategory;
                MList.ItemType     = RCModel.ItemType;
                MList.ItemName     = RCModel.ItemName;
                MList.ItemNumber   = RCModel.ItemNumber;
                MList.Manufacturer = RCModel.Manufacturer;
                MList.ItemFilename = null;
                if (MList.ID != 0)
                {
                    IEnumerable <InventoryMedia> IMList = App.Database.GetMediaRecs(MList.ID);
                    foreach (InventoryMedia IMRec in IMList)
                    {
                        // Load Model Name by looking up the ItemID in the InventoryItem table.
                        MList.ItemFilename = IMRec.Filename;
                        break;
                    }
                }
                IEnumerable <ActivityLog> ActivityLogs = App.Database.GetActivityRecs(MList.ID);
                MList.NoOfFlights = ActivityLogs.Count <ActivityLog>().ToString();
                //
                int iTotalFlightTimeInSeconds = 0;
                foreach (ActivityLog ALog in ActivityLogs)
                {
                    if (ALog.ActivityType == "TIME TRACKING REPORT")
                    {
                        iTotalFlightTimeInSeconds += ALog.LogTimeInSeconds;
                    }
                }
                if (iTotalFlightTimeInSeconds != 0)
                {
                    MList.TotalFlightTimeInSeconds = iTotalFlightTimeInSeconds.ToString();
                    //
                    // MM = 550 / 60
                    int iTotalHH = 0;
                    int iTotalMM = iTotalFlightTimeInSeconds / 60;
                    int iTotalSS = iTotalFlightTimeInSeconds % 60;
                    if (iTotalMM > 60)
                    {
                        iTotalHH = iTotalMM / 60;
                        iTotalMM = iTotalMM % 60;
                    }
                    MList.TotalFlightTimeHHMMSS = "";
                    if (iTotalHH != 0)
                    {
                        MList.TotalFlightTimeHHMMSS += iTotalHH.ToString() + ":";
                    }
                    MList.TotalFlightTimeHHMMSS += iTotalMM.ToString() + ":";
                    MList.TotalFlightTimeHHMMSS += iTotalSS.ToString();
                }
                //
                RCModelLV.Add(MList);
            }
        }
Example #22
0
 public GameClient()
 {
     AdditionalData = new ObjectPropertyList();
     InventoryItems = new InventoryItemList();
 }
        /// <summary>
        /// Initializes a new instance of class.
        /// </summary>
        /// <param name="model">Instance we want to display</param>
        public RCInventoryDetailsView(InventoryItemList model, string sItemCategory)
        {
            // Bind our BindingContext
            Model = model;

            NavigationPage.SetHasNavigationBar(this, true);

            InitializeComponent();
            // If a specific Item Category is passed into screen then set as category of item being entered.
            if (sItemCategory != "")
            {
                Model.ItemCategory = sItemCategory;
            }
            switch (sItemCategory)
            {
            case App.ItemCategory_MODEL:
                labelItemType.Text = "Model Type";
                IEnumerable <ActivityLog> ActivityLogs = App.Database.GetActivityRecs(Model.ID);
                int iTotalFlightTimeInSeconds          = 0;
                foreach (ActivityLog ALog in ActivityLogs)
                {
                    if (ALog.ActivityType == "TIME TRACKING REPORT")
                    {
                        iTotalFlightTimeInSeconds += ALog.LogTimeInSeconds;
                    }
                }
                labelNoOfFlights.Text    = iTotalFlightTimeInSeconds.ToString();
                lblBatteryNo.IsVisible   = false;
                EntryBatteryNo.IsVisible = false;
                //
                lblDefaultTime.IsVisible = true;
                EntryMinutes.IsVisible   = true;
                lblColon.IsVisible       = true;
                EntrySeconds.IsVisible   = true;
                break;

            case App.ItemCategory_BATTERY:
                labelItemType.IsVisible  = false;
                entryItemType.IsVisible  = false;
                lblBatteryNo.IsVisible   = true;
                EntryBatteryNo.IsVisible = true;
                lblDefaultTime.IsVisible = false;
                EntryMinutes.IsVisible   = false;
                lblColon.IsVisible       = false;
                EntrySeconds.IsVisible   = false;
                break;
            }

            //
            if (Model.PurchaseDate == DateTime.MinValue)
            {
                DTPicker.Date = DateTime.Now;
            }
            else
            {
                DTPicker.Date = Model.PurchaseDate;
            }
            //
            // Save Button
            btnSaveSC.Clicked += (sender, e) =>
            {
                //var todoItem = (TodoItem)BindingContext;
                //
                Model.PurchaseDate = DTPicker.Date;
                InventoryItem IIRec = TransferToInventoryItemRec(Model);
                Model.ID = App.Database.SaveItem(IIRec);
                Navigation.PopAsync();
            };
            //
            // Cancel Button
            btnCancelSC.Clicked += (sender, e) =>
            {
                Navigation.PopAsync();
            };
            //
            // Delete Button
            btnDeleteSC.Clicked += (sender, e) =>
            {
                App.Database.DeleteItem(Model.ID);
                Navigation.PopAsync();
            };
            //
            // No of Flights Button
            btnNoOfFlights.Clicked += (sender, e) =>
            {
                // create a new details view with the item
                var view = new ActivityLogListView(Model.ID);
                //// tell the navigator to show the new view
                Navigation.PushAsync(view);
            };
            //
            // List Media Button
            btnGallery.Clicked += (sender, e) =>
            {
                Model.PurchaseDate = DTPicker.Date;
                InventoryItem IIRec = TransferToInventoryItemRec(Model);
                Model.ID = App.Database.SaveItem(IIRec);
                // create a new details view with the item
                var view = new MediaListView(Model.ID);
                //// tell the navigator to show the new view
                Navigation.PushAsync(view);
            };
            //
            // Display Item Name list
            entryItemType.Focused += (sender, e) =>
            {
                _sCurrentListType = "ITEMTYPE";
                // create a new details view with the item
                var view = new ListDataListView(_sCurrentListType, true);
                //// tell the navigator to show the new view
                Navigation.PushAsync(view);
            };
            //
            // Display Manufacturer list
            btnListManuf.Clicked += (sender, e) =>
            {
                _sCurrentListType = "MANUFACTURER";
                // create a new details view with the item
                var view = new ListDataListView(_sCurrentListType, true);
                //// tell the navigator to show the new view
                Navigation.PushAsync(view);
            };
            //
            //LoadItemNamePicker();
        }
Example #24
0
 void Start()
 {
     //WeaponList at the moment (Contains other items as well)
     itemDatabase = (InventoryItemList)Resources.Load("ItemDatabase/InventoryItemList");
 }
Example #25
0
 void OpenItemList()
 {
     string absPath = EditorUtility.OpenFilePanel("Select Inventory Item List", "", "");
     if(absPath.StartsWith(Application.dataPath)){
         string relPath = absPath.Substring(Application.dataPath.Length - "Assets".Length);
         inventoryItemList = AssetDatabase.LoadAssetAtPath(relPath, typeof(InventoryItemList)) as InventoryItemList;
         if(inventoryItemList){
             EditorPrefs.SetString("ObjectPath", relPath);
         }
     }
 }
Example #26
0
        // TODO: Get hovered items && items from inventory - Getting hovered itemw ill become useful later on

        public override void Render()
        {
            try // Im lazy and just want to surpress all errors produced
            {
                // only update if the time between last update is more than AutoReloadTimer interval
                if (Settings.AutoReload && Settings.LastUpDateTime.AddMinutes(Settings.AutoReloadTimer.Value) < DateTime.Now)
                {
                    LoadJsonData();
                    Settings.LastUpDateTime = DateTime.Now;
                }

                if (Settings.Debug)
                {
                    LogMessage($"{GetCurrentMethod()}.Loop() is Alive", 5, Color.LawnGreen);
                }

                #region Reset All Data

                CurrentLeague = Settings.LeagueList.Value; //  Update selected league every tick
                StashTabValue = 0;
                Hovereditem   = null;
                ItemsToDrawList.Clear();
                InventoryItemsToDrawList.Clear();
                StashPanel = GameController.Game.IngameState.ServerData.StashPanel;

                #endregion

                if (Settings.Debug)
                {
                    LogMessage($"{GetCurrentMethod()}: Selected League: {Settings.LeagueList.Value}", 5, Color.White);
                }

                // Everything is updated, lets check if we should draw
                if (!StashPanel.IsVisible)
                {
                    return;
                }

                if (ShouldUpdateValues())
                {
                    // Format stash items
                    ItemList.Clear();
                    ItemList           = StashPanel.VisibleStash.VisibleInventoryItems.ToList();
                    FortmattedItemList = FormatItems(ItemList);

                    // Format Inventory Items
                    InventoryItemList.Clear();
                    InventoryItemList           = GetInventoryItems();
                    FortmattedInventoryItemList = FormatItems(InventoryItemList);

                    if (Settings.Debug)
                    {
                        LogMessage($"{GetCurrentMethod()}.Render() Looping if (ShouldUpdateValues())", 5, Color.LawnGreen);
                    }

                    foreach (var item in FortmattedItemList)
                    {
                        GetValue(item);
                    }
                }

                // Gather all information needed before rendering as we only want to itterate through the list once

                foreach (var item in FortmattedItemList)
                {
                    if (item == null || item.Item.Address == 0)
                    {
                        continue;                                         // Item is f****d, skip
                    }
                    if (!item.Item.IsVisible && item.ItemType != ItemTypes.None)
                    {
                        continue;                                                          // Disregard non visable items as that usually means they arnt part of what we want to look at
                    }
                    StashTabValue += item.PriceData.ChaosValue;
                    ItemsToDrawList.Add(item);
                }
                foreach (var item in FortmattedInventoryItemList)
                {
                    if (item == null || item.Item.Address == 0)
                    {
                        continue;                                         // Item is f****d, skip
                    }
                    if (!item.Item.IsVisible && item.ItemType != ItemTypes.None)
                    {
                        continue;                                                          // Disregard non visable items as that usually means they arnt part of what we want to look at
                    }
                    InventoryItemsToDrawList.Add(item);
                }

                GetHoveredItem(); // Get information for the hovered item

                // TODO: Graphical part from gathered data

                DrawGraphics();
            }
            catch
            {
                // ignored
            }

            try
            {
                PropheccyDisplay();
            }
            catch
            {
                LogMessage("Error in: PropheccyDisplay(), restart PoEHUD.", 5);
            }
        }