// Use this for initialization
    void Awake()
    {

        researchWindowData = gameObject.transform.parent.gameObject.transform.parent.gameObject.GetComponent<ResearchWindow>();
        playerAttributeControlData = GameObject.Find("01_Player").GetComponent<PlayerAttributeControl>();

    } // END Awake
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        playerAttributeControlData = gameObject.GetComponent <PlayerAttributeControl>();

        researchObject         = GameObject.Find("00_GuiStuff");
        menuResearchWindowData = researchObject.GetComponent <ResearchWindow>();
        menuStorageWindowData  = researchObject.GetComponent <StorageWindow>();
        menuFactoryWindowData  = researchObject.GetComponent <FactoryWindow>();
    }     // END Start
	// Use this for initialization
	void Start () {
        
        playerAttributeControlData = gameObject.GetComponent<PlayerAttributeControl>();

        researchObject = GameObject.Find("00_GuiStuff");
        menuResearchWindowData = researchObject.GetComponent<ResearchWindow>();
        menuStorageWindowData = researchObject.GetComponent<StorageWindow>();
        menuFactoryWindowData = researchObject.GetComponent<FactoryWindow>();

	} // END Start
Exemplo n.º 4
0
        public override void PreOpen()
        {
            base.PreOpen();

            closeOnClickedOutside = false;

            SetRects();

            if (!initialized)
            {
                researchWindow    = new ResearchWindow();
                defExplorerWindow = new DefExplorerWindow();
                openWindow        = profileManagerWindow;
                backTex           = ContentFinder <Texture2D> .Get("Buttons/rimEditBack");

                backTexGrey = ContentFinder <Texture2D> .Get("Buttons/rimEditBackGrey");

                forwardTex = ContentFinder <Texture2D> .Get("Buttons/rimEditForward");

                forwardTexGrey = ContentFinder <Texture2D> .Get("Buttons/rimEditForwardGrey");

                initialized = true;
            }
        }
Exemplo n.º 5
0
 public bool TrySetValue(object obj)
 {
     if (obj is string stringObj)
     {
         if (!IsConvertibleFromText(field.FieldType))
         {
             Verse.Log.Error("Tried to convert from text to object not convertible");
             Reset();
             return(false);
         }
         object newVal;
         if (stringObj == "null")
         {
             newVal = null;
         }
         else
         {
             try
             {
                 newVal = Convert.ChangeType(stringObj, field.FieldType);
             }
             catch
             {
                 Dialog_MessageBox invalid = new Dialog_MessageBox("Invalid value for " + field.FieldType);
                 Verse.Find.WindowStack.Add(invalid);
                 Reset();
                 return(false);
             }
         }
         string command = MakeSetCommand(newVal);
         AddCommand(command);
         field.SetValue(parent, newVal);
         Reset();
         return(true);
     }
     else
     {
         if (obj != null && !field.FieldType.IsAssignableFrom(obj.GetType()))
         {
             Verse.Log.Error("Tried to assign object of wrong type");
             Reset();
             return(false);
         }
         string command = MakeSetCommand(obj);
         AddCommand(command);
         bool refreshResearch = false;
         if (parent is ResearchProjectDef)
         {
             if (obj is TechLevel tl)
             {
                 if (!Research.Tree.RelevantTechLevels.Contains(tl))
                 {
                     refreshResearch = true;
                 }
             }
         }
         field.SetValue(parent, obj);
         Reset();
         if (refreshResearch)
         {
             ResearchWindow.Refresh();
         }
         return(true);
     }
 }
Exemplo n.º 6
0
        public override void DoWindowContents(Rect inRect)
        {
            //Rect researchButtonRect = topButtonsRect.LeftPartPixels(50);
            bool profileSet = ProfileManager.activeProfile != null;
            // Top Bar --------------------------------------------------------------------
            Rect backRect = topBarRect.LeftPartPixels(Text.LineHeight + 13f);

            backRect.height = Text.LineHeight + 13f;
            if (backStack.Count > 0)
            {
                bool back = Widgets.ButtonImage(backRect, backTex, baseColor: lightGrey, mouseoverColor: Color.white, doMouseoverSound: true);
                if (back)
                {
                    Back();
                }
            }
            else
            {
                Widgets.DrawTextureFitted(backRect, backTexGrey, 1f);
            }

            GUI.color = Color.white;

            Rect forwardRect = new Rect(backRect.xMax + 4f, backRect.y, backRect.width, backRect.height);

            if (forwardStack.Count > 0)
            {
                bool forward = Widgets.ButtonImage(forwardRect, forwardTex, baseColor: lightGrey, mouseoverColor: Color.white, doMouseoverSound: true);
                if (forward)
                {
                    Forward();
                }
            }
            else
            {
                Widgets.DrawTextureFitted(forwardRect, forwardTexGrey, 1f);
            }

            GUI.color = Color.white;

            Rect profileManagerRect    = new Rect(forwardRect.xMax + 4f, forwardRect.y, 125f, forwardRect.height);
            bool profileManagerClicked = Widgets.ButtonText(profileManagerRect, "Profiles");

            Rect researchRect    = new Rect(profileManagerRect.xMax + 4f, profileManagerRect.y, profileManagerRect.width, profileManagerRect.height);
            bool researchClicked = Widgets.ButtonText(researchRect, "Research", textColor: profileSet ? Color.white : Color.grey, drawBackground: profileSet, doMouseoverSound: profileSet, active: profileSet);

            Rect defExplorerRect = new Rect(researchRect.xMax + 4f, profileManagerRect.y, profileManagerRect.width, profileManagerRect.height);
            bool explorerClicked = Widgets.ButtonText(defExplorerRect, "Def Explorer", textColor: profileSet ? Color.white : Color.grey, drawBackground: profileSet, doMouseoverSound: profileSet, active: profileSet);



            float topRightBarx      = bottomBarRect.xMax - 25f - Margin;
            float topRightBarHeight = Text.LineHeight + 13f;

            if (openWindow == researchWindow)
            {
                float refreshWidth = 75f;
                topRightBarx -= (refreshWidth);
                Rect refreshRect = new Rect(topRightBarx, profileManagerRect.y, refreshWidth, topRightBarHeight);
                bool refresh     = Widgets.ButtonText(refreshRect, "Refresh");

                if (refresh)
                {
                    ResearchWindow.Refresh();
                    return;
                }
                float dummiesWidth = 150f;
                topRightBarx -= (dummiesWidth + 5f);
                Rect showDummiesRect = new Rect(topRightBarx, profileManagerRect.y, dummiesWidth, topRightBarHeight);
                Widgets.CheckboxLabeled(showDummiesRect, "Show Dummies", ref ResearchWindow.drawDummies);
            }

            // Bottom Bar --------------------------------------------------------------------
            float buttonHeight    = Text.LineHeight + 13f;
            Rect  saveProfileRect = bottomBarRect.LeftPartPixels(100f);

            saveProfileRect.yMin   = bottomBarRect.yMax - 50f;
            saveProfileRect.height = buttonHeight;
            bool saveProfile = Widgets.ButtonText(saveProfileRect, "Save Profile", textColor: profileSet ? Color.white : Color.grey, drawBackground: profileSet, doMouseoverSound: profileSet, active: profileSet);

            Rect   unsavedChangesRect = new Rect(saveProfileRect.xMax + 4f, saveProfileRect.y + (saveProfileRect.height / 3.0f), 150f, saveProfileRect.height);
            string unsavedText        = "";

            if (ProfileManager.unsavedChanges)
            {
                unsavedText = "(unsaved changes)";
            }
            Widgets.Label(unsavedChangesRect, unsavedText);

            Rect closeRect = new Rect(bottomBarRect.xMax - 100f - Margin, saveProfileRect.yMin, 60f, Text.LineHeight + 13f);
            bool close     = Widgets.ButtonText(closeRect, "Close");

            // Clicks --------------------------------------------------------------------


            if (profileManagerClicked || !profileSet)
            {
                Open(profileManagerWindow, true);
            }
            else if (researchClicked)
            {
                Open(researchWindow, true);
            }
            else if (explorerClicked)
            {
                Open(defExplorerWindow, true);
            }

            if (saveProfile && profileSet)
            {
                ProfileManager.SaveChanges();
            }

            if (close)
            {
                FileManager.SaveConfig();
                Find.WindowStack.TryRemove(typeof(MainWindow));
            }

            if (openWindow != null)
            {
                openWindow.DoWindowContents(viewRect);
            }
        }
 // Use this for initialization
 void Awake()
 {
     researchWindowData         = gameObject.transform.parent.gameObject.transform.parent.gameObject.GetComponent <ResearchWindow>();
     playerAttributeControlData = GameObject.Find("01_Player").GetComponent <PlayerAttributeControl>();
 } // END Awake