Exemplo n.º 1
0
        public NewRoomDialog(IGuiManager guiManager)
            : base(guiManager, mGuiPath)
        {
            Pair <IGuiFrame>[] progressSteps = new Pair <IGuiFrame> [mProgressFrameNames.Length];
            for (int i = 0; i < progressSteps.Length; ++i)
            {
                progressSteps[i] = new Pair <IGuiFrame>();
            }

            // Grab the references to the required elements
            foreach (IGuiElement element in this.AllElements)
            {
                if (element is Window && element.Name == "NewRoomDialog")
                {
                    mMainWindow = (Window)element;
                }
                else if (element is IGuiFrame)
                {
                    IGuiFrame frame = (IGuiFrame)element;
                    for (int i = 0; i < mProgressFrameNames.Length; ++i)
                    {
                        if (frame.Name == mProgressFrameNames[i].First)
                        {
                            progressSteps[i].First = frame;
                        }
                        else if (frame.Name == mProgressFrameNames[i].Second)
                        {
                            progressSteps[i].Second = frame;
                        }
                    }
                }
                else
                {
                    throw new Exception("Unexpected " + element.GetType().Name + "(" + element.Name + ") found in the root of GUI XML(" + mGuiPath + ")");
                }
            }

            // Check to make sure all the frames are in the XML
            for (int i = 0; i < progressSteps.Length; ++i)
            {
                string failName = null;
                if (progressSteps[i].First == null)
                {
                    failName = mProgressFrameNames[i].First;
                }
                else if (progressSteps[i].Second == null)
                {
                    failName = mProgressFrameNames[i].Second;
                }
                if (failName != null)
                {
                    throw new Exception("Unable to find frame(" + failName + ") in the root of " + mGuiPath);
                }
            }

            if (mMainWindow == null)
            {
                throw new Exception("Unable to find Window(NewRoomDialog) in the root of " + mGuiPath);
            }
            mMainWindow.Showing = false;

            mProgressView = BuildProgressView(progressSteps, this.GetNamedStyle("NavbarButton"));
            SetupProgressButtons(progressSteps);
            mProgressView.GoToStep(0);
        }