Exemple #1
0
    private void Start()
    {
        researcher       = GameController.instance.researcher;
        descriptionPanel = GameController.instance.buttons.GetDescriptionPanel(this);

        researchPanel = descriptionPanel.transform.GetChild(1).GetComponent <ResearchPanel>();
        resourcePanel = descriptionPanel.transform.GetChild(2).GetComponent <ResourcePanel>();
    }
Exemple #2
0
 /// <summary>
 /// This function waits until the MoveUpThread is done(meaning the ClassesPanel has moved off screen),
 /// and then it calls AddResourcesAfterWait on the GUI thread. If MoveUpThread is null it simply calls AddResourcesAfterWait
 /// on the GUI thread. This function should only be called by UpdateResources.
 /// </summary>
 /// <param name="Resources"></param>
 private void UpdateResourcesHelper(List <ResourceData> Resources)
 {
     if (MoveUpThread != null)
     {
         MoveUpThread.Join();
         MoveUpThread = null;
     }
     ResourcePanel.Invoke((AddResourcesDelegate)AddResourcesAfterWait, Resources, CurrentPage);
 }
Exemple #3
0
        void RefreshState()
        {
            if (tasks == null || resources == null)
            {
                return;
            }
            GetTimeUnit(out MinorTimeUnit, out TimeUnitCountPerMajorUnit);
            int width = 0;

            for (int i = 0; i < tasks.Length; i++)
            {
                width = Math.Max(width, (int)((tasks[i].PlannedDuration + tasks[i].PlannedStart) * ScaleFactor));
            }
            int rowCount = tasks.Length + 1;

            width = width + 200;
            width = Math.Max(width, TaskContainer.Width);

            int height = TimeRowHeight + rowCount * RowHeight;

            height         = Math.Max(height, TaskContainer.Height);
            TaskPanel.Size = new Size(width, height);

            TaskNamePanel.Size = new Size(
                Math.Max(nameColumnWidth, TaskNamePanel.Width),
                Math.Max(RowHeight * tasks.Length + TimeRowHeight, TaskNamePanel.Height));

            rowCount = 0;
            for (int i = 0; i < resources.Length; i++)
            {
                rowCount += resources[i].Count;
            }
            ResourceNamePanel.Size = new Size(
                Math.Max(nameColumnWidth, ResourceNamePanel.Width),
                Math.Max(RowHeight * rowCount, ResourceNamePanel.Height));
            width              = Math.Max(width, ResourceContainer.Width);
            height             = Math.Max(RowHeight * rowCount, ResourceContainer.Height);
            ResourcePanel.Size = new Size(
                width,
                height);

            TaskContainer.HorizontalScroll.Enabled = false;
            TaskContainer.HorizontalScroll.Visible = false;

            LeftContainer.Width = nameColumnWidth;

            TaskPanel.Refresh();
            TaskNamePanel.Refresh();
            ResourceNamePanel.Refresh();
            ResourcePanel.Refresh();
            TimePanel.Refresh();
            ShowScrollBar(TaskContainer.Handle, (int)ScrollBarDirection.SB_HORZ, false);
        }
 public static void PatchVersion_Bind(ResourcePanel __instance)
 {
     try
     {
         var patcher     = _instance._patcher;
         var versionText = patcher.GetField <LocalizedText>(__instance, "m_versionText");
         versionText.Text += " (UMC)";
         _instance._logger.Debug("Patched version text!");
     }
     catch (Exception ex)
     {
         _instance._logger.Error("Error patching version text: " + ex);
     }
 }
Exemple #5
0
    private void OnLoad()
    {
        this.level          = playerData.level;
        this.experience     = playerData.experience;
        this.finances       = playerData.finances;
        this.skills         = playerData.skills;
        this.activeQuests   = playerData.quests;
        this.hasAutoClicker = playerData.hasAutoClicker;
        this.premiumState   = playerData.premiumState;
        List <Quest> allQuests = FindObjectOfType <QuestGiver>().allQuests;

        foreach (Quest q in allQuests)
        {
            foreach (Quest a in activeQuests)
            {
                a.goal.StopListeningToObjective();
                if (q.Name == a.Name)
                {
                    q.isActive           = a.isActive;
                    q.goal.currentAmount = a.goal.currentAmount;
                    q.duration           = a.duration;
                    StartCoroutine(q.Load());
                }
            }
        }
        List <string> questNames = new List <string>();

        foreach (Quest q in activeQuests)
        {
            questNames.Add(q.Name);
        }
        foreach (Quest q in allQuests)
        {
            if (questNames.Contains(q.Name))
            {
                activeQuests.Remove(activeQuests.Where(x => x.Name == q.Name).LastOrDefault());
                activeQuests.Add(q);
            }
        }

        ResourcePanel r = resources.rPanel;

        this.resources        = playerData.resources;
        this.resources.rPanel = r;
        panel.SetPanel();
    }
Exemple #6
0
        /// <summary>
        /// Adds a bank to the resourcemanager
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void InsertBankMenu_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter     = "Resource bank (*.bnk)|*.bnk|All Files (*.*)|*.*";
            dlg.Title      = "Select resource to open...";
            dlg.DefaultExt = ".bnk";

            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            ResourceManager.AddStorage(new BankStorage(dlg.FileName));

            ResourcePanel.RebuildResourceTree();
        }
Exemple #7
0
        /// <summary>
        /// Adds a binary to the bank
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddBinary_OnClick(object sender, EventArgs e)
        {
            if (Storage == null)
            {
                return;
            }

            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter           = "All Files (*.*)|*.*";
            dlg.Title            = "Select a binary file...";
            dlg.DefaultExt       = ".*";
            dlg.Multiselect      = true;
            dlg.RestoreDirectory = true;

            DialogResult res = dlg.ShowDialog();

            if (res != DialogResult.OK)
            {
                return;
            }

            for (int i = 0; i < dlg.FileNames.Length; i++)
            {
                // Open storage file
                using (Stream to = Storage.OpenFile(dlg.FileNames[i], FileAccess.Write))
                {
                    // Temp memory stream
                    MemoryStream mem = new MemoryStream();

                    // Open file to copy
                    using (Stream from = new FileStream(dlg.FileNames[i], FileMode.Open))
                    {
                        mem.SetLength(from.Length);
                        from.Read(mem.GetBuffer(), 0, (int)from.Length);
                        mem.Flush();
                    }

                    mem.WriteTo(to);

                    mem.Close();
                }
            }

            ResourcePanel.RebuildResourceTree();
        }
Exemple #8
0
 /// <summary>
 /// This function takes care of transitioning from The Resources View to the Classes View when the top left Arrow is clicked.
 /// It also clears out the CurrentResources.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ArrowPanel_Click(object sender, EventArgs e)
 {
     if (ClassView)
     {
         return;
     }
     else
     {
         AddFilePanel.Hide();
         AddLinkPanel.Hide();
         CurrentPage            = 0;
         CurrentClassLabel.Text = "";
         DeleteSempahore.WaitOne();
         ClassView = true;
         CurrentResources.Clear(); //Throw away the resources because the class is changing.
         ClassesPanel.Location = new Point(136, 150);
         ClassesPanel.BringToFront();
         ClassesPanel.Show();
         ResourcePanel.Hide();
     }
 }
Exemple #9
0
        /// <summary>
        /// Creates an empty resource bank
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CreateNewBank(object sender, EventArgs e)
        {
            DialogResult res = MessageBox.Show("Erase all resources ?", "", MessageBoxButtons.YesNo);

            if (res != DialogResult.Yes)
            {
                return;
            }

            CloseAllTabs_OnClick(null, null);
            ResourceManager.ClearAssets();

            // New bank name
            if (Storage != null)
            {
                Storage.Dispose();
            }
            Storage = null;

            //
            ResourcePanel.RebuildResourceTree();
        }
Exemple #10
0
        /// <summary>
        ///  Adds resource to the manager
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuTool_AddExistingResource_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter     = "Resource bank (*.bnk)|*.bnk|All Files (*.*)|*.*";
            dlg.Title      = "Select resource to open...";
            dlg.DefaultExt = ".bnk";

            DialogResult res = dlg.ShowDialog();

            if (res != DialogResult.OK)
            {
                return;
            }

            // Stay back in the good directory
            Environment.CurrentDirectory = Application.StartupPath;


            ResourceManager.AddStorage(new BankStorage(dlg.FileName));

            ResourcePanel.RebuildResourceTree();
        }
Exemple #11
0
 /// <summary>
 /// Creates a new asset
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void NewAssetBox_Click(object sender, EventArgs e)
 {
     new WizardForm(dockPanel, null).ShowDialog();
     ResourcePanel.RebuildResourceTree();
 }
Exemple #12
0
    // Use this for initialization
    void Start()
    {
        instance = this;

        UpdateAmounts();
    }
Exemple #13
0
 void OnDestroy()
 {
     instance = null;
 }
Exemple #14
0
 public void RegisterResourcePanel(string key, ResourcePanel panel)
 {
     resourcePanels[key] = panel;
 }
 private void Awake()
 {
     instance = this;
 }
Exemple #16
0
 /// <summary>
 /// Import an animation from a GIF image
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ImportAnimationFromGIF(object sender, EventArgs e)
 {
     new ImportGIFForm(Storage).ShowDialog();
     ResourcePanel.RebuildResourceTree();
 }
Exemple #17
0
 /// <summary>
 /// Collapse resource tree
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void CollapseTreeMenu_Click(object sender, EventArgs e)
 {
     ResourcePanel.CollapseTree();
 }
Exemple #18
0
        /// <summary>
        /// This function was made to be called by UpdateResourcesHelper only. It creates an object for every item in CurrentResources
        /// and paints it onto the ResourcePanel. It's in charge of knowing which resources to put on the pages and where. It updates
        /// Comments.
        /// </summary>
        /// <param name="Resources"></param>
        /// <param name="PageNum"></param>
        private void AddResourcesAfterWait(List <ResourceData> Resources, int PageNum)
        {
            ControlHelper.SuspendDrawing(ResourcePanel);
            ResourcePanel.Show();
            ResourcePanel.BringToFront();
            int count = 0; //Used for colors.

            //Add to left page
            for (int i = PageNum * 32; i < PageNum * 32 + 16; i++)
            {
                if (i >= Resources.Count)
                {
                    break;
                }
                if (Resources[i].Name.Equals("_Class_Foot_In_Door")) //This Resource is just to keep new classes available on server.
                {
                    continue;
                }
                int ColorNum;
                if (Resources[i].Unit == null || Resources[i].Unit.Equals(""))
                {
                    ColorNum = CurrentBookColorComplement;
                }
                else
                {
                    string UnitExt = Resources[i].Unit.Substring(Resources[i].Unit.Length - 3);
                    ColorNum = ColorExtensions.IndexOf(UnitExt);
                }
                PagePanel current = new PagePanel(Resources[i].Name, Resources[i].Date, Resources[i].Type, Resources[i].Link != null, (ResourceColor)ColorNum);
                Comments.Add(Resources[i].Name, Resources[i].Comments);
                current.AddTo(ResourcesLeftPanel);
                current.Delete_Clicked += Received_Delete;
                current.Double_Clicked += Received_Double_Click;
                current.Right_Clicked  += Received_Right_Click;

                Copy_Right_Label.BringToFront();
            }

            //Add to right page
            for (int i = PageNum * 32 + 16; i < PageNum * 32 + 32; i++)
            {
                if (i >= Resources.Count)
                {
                    break;
                }
                if (Resources[i].Name.Equals("_Class_Foot_In_Door")) //This Resource is just to keep new classes available on server.
                {
                    continue;
                }
                int ColorNum;
                if (Resources[i].Unit == null || Resources[i].Unit.Equals(""))
                {
                    ColorNum = CurrentBookColorComplement;
                }
                else
                {
                    string UnitExt = Resources[i].Unit.Substring(Resources[i].Unit.Length - 3);
                    ColorNum = ColorExtensions.IndexOf(UnitExt);
                }
                PagePanel current = new PagePanel(Resources[i].Name, Resources[i].Date, Resources[i].Type, Resources[i].Link != null, (ResourceColor)ColorNum);
                Comments.Add(Resources[i].Name, Resources[i].Comments);
                current.AddTo(ResourcesRightPanel);
                current.Delete_Clicked += Received_Delete;
                current.Double_Clicked += Received_Double_Click;
                current.Right_Clicked  += Received_Right_Click;
            }
            ControlHelper.ResumeDrawing(ResourcePanel);
        }
Exemple #19
0
 /// <summary>
 /// Expand resource tree
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ExpandTreeMenu_Click(object sender, EventArgs e)
 {
     ResourcePanel.ExpandTree();
 }