Ejemplo n.º 1
0
    /// <summary>
    /// Parse the downloaded remote manifest and start download of individual quest files
    /// </summary>
    public void DownloadManifest_callback(string data, bool error)
    {
        if (error)
        {
            // Hide loading screen
            Destroyer.Dialog();

            // draw error message
            float     error_string_width = 0;
            UIElement ui = new UIElement();
            if (data == "ERROR NETWORK")
            {
                StringKey ERROR_NETWORK = new StringKey("val", "ERROR_NETWORK");
                ui.SetText(ERROR_NETWORK, Color.red);
                error_string_width = ui.GetStringWidth(ERROR_NETWORK, UIScaler.GetMediumFont());
            }
            else
            {
                StringKey ERROR_HTTP = new StringKey("val", "ERROR_HTTP", game.stats.error_download_description);
                ui.SetText(ERROR_HTTP, Color.red);
                error_string_width = ui.GetStringWidth(ERROR_HTTP, UIScaler.GetMediumFont());
            }
            ui.SetLocation(UIScaler.GetHCenter() - (error_string_width / 2f), UIScaler.GetVCenter(), error_string_width, 2.4f);
            ui.SetTextAlignment(TextAnchor.MiddleCenter);
            ui.SetFontSize(UIScaler.GetLargeFont());
            ui.SetBGColor(Color.clear);

            // draw return button
            ui = new UIElement();
            ui.SetLocation(1, UIScaler.GetBottom(-3), 8, 2);
            ui.SetText(CommonStringKeys.BACK, Color.red);
            ui.SetButton(delegate { Cancel(); });
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());
            new UIElementBorder(ui, Color.red);

            return;
        }

        IniData remoteManifest = IniRead.ReadFromString(data);

        foreach (KeyValuePair <string, Dictionary <string, string> > kv in remoteManifest.data)
        {
            remoteQuests.Add(new RemoteQuest(kv));
        }
        DownloadQuestFiles();
    }
Ejemplo n.º 2
0
    public MenuButton()
    {
        TextButton qb;

        if (Game.Get().editMode)
        {
            qb = new TextButton(new Vector2(UIScaler.GetRight(-9), UIScaler.GetBottom(-3)), new Vector2(8, 2), "Menu", delegate { Menu(); }, Color.red);
        }
        else
        {
            qb = new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), "Menu", delegate { Menu(); }, Color.red);
        }

        // Untag as dialog so this isn't cleared away

        qb.ApplyTag("questui");
    }
Ejemplo n.º 3
0
        public QuestSelectionScreen(Dictionary <string, QuestLoader.Quest> ql)
        {
            questList = ql;
            Game game = Game.Get();

            // If a dialog window is open we force it closed (this shouldn't happen)
            foreach (GameObject go in GameObject.FindGameObjectsWithTag("dialog"))
            {
                Object.Destroy(go);
            }

            // Clean up downloader if present
            foreach (GameObject go in GameObject.FindGameObjectsWithTag("questui"))
            {
                Object.Destroy(go);
            }

            // Heading
            DialogBox db = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 3), "Select " + game.gameType.QuestName());

            db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont();
            db.SetFont(game.gameType.GetHeaderFont());

            TextButton tb;
            // Start here
            int offset = 5;

            // Loop through all available quests
            // FIXME: this isn't paged
            foreach (KeyValuePair <string, QuestLoader.Quest> q in questList)
            {
                string key = q.Key;
                // Size is 1.2 to be clear of characters with tails
                tb = new TextButton(new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 4, 1.2f), "  " + q.Value.name, delegate { Selection(key); }, Color.white, offset);
                tb.button.GetComponent <UnityEngine.UI.Text>().fontSize   = UIScaler.GetSmallFont();
                tb.button.GetComponent <UnityEngine.UI.Text>().alignment  = TextAnchor.MiddleLeft;
                tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0, 0.1f);
                offset += 2;
            }

            tb = new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), "Back", delegate { Cancel(); }, Color.red);
            tb.SetFont(game.gameType.GetHeaderFont());

            tb = new TextButton(new Vector2(UIScaler.GetRight(-9), UIScaler.GetBottom(-3)), new Vector2(8, 2), "Download", delegate { Download(); }, Color.green);
            tb.SetFont(game.gameType.GetHeaderFont());
        }
Ejemplo n.º 4
0
    // Construct and display
    public NextStageButton()
    {
        if (Game.Get().gameType.DisplayHeroes())
        {
            return;
        }
        TextButton tb = new TextButton(new Vector2(UIScaler.GetHCenter(10f), UIScaler.GetBottom(-2.5f)), new Vector2(4, 2), "->", delegate { Next(); });

        // Untag as dialog so this isn't cleared away
        tb.ApplyTag("questui");
        tb = new TextButton(new Vector2(UIScaler.GetHCenter(-14f), UIScaler.GetBottom(-2.5f)), new Vector2(4, 2), "Log", delegate { Log(); });
        // Untag as dialog so this isn't cleared away
        tb.ApplyTag("questui");
        tb = new TextButton(new Vector2(UIScaler.GetHCenter(-10f), UIScaler.GetBottom(-2.5f)), new Vector2(4, 2), "Set", delegate { Set(); });
        // Untag as dialog so this isn't cleared away
        tb.ApplyTag("questui");
        Update();
    }
Ejemplo n.º 5
0
        public void CheckForNewValkyrieVersion()
        {
            StringKey NEW_VERSION_AVAILABLE = new StringKey("val", "NEW_VERSION_AVAILABLE");

            if (VersionManager.VersionNewer(Game.Get().version, VersionManager.online_version))
            {
                float     string_width = 0f;
                UIElement ui           = new UIElement();
                ui.SetText(NEW_VERSION_AVAILABLE, Color.green);
                string_width = ui.GetStringWidth(NEW_VERSION_AVAILABLE, UIScaler.GetMediumFont());
                ui.SetLocation(UIScaler.GetRight() - 3 - string_width, UIScaler.GetBottom(-3), string_width + 2, 2);
                ui.SetText(NEW_VERSION_AVAILABLE, Color.green);
                ui.SetFontSize(UIScaler.GetMediumFont());
                ui.SetButton(delegate { GotoWebBrowser(VersionManager.GetlatestReleaseURL()); });
                ui.SetBGColor(new Color(0, 0.03f, 0f));
                new UIElementBorder(ui, Color.green);
            }
        }
Ejemplo n.º 6
0
    public MenuButton()
    {
        Game       game = Game.Get();
        TextButton qb;

        // For the editor button is moved to the right
        if (Game.Get().editMode)
        {
            qb = new TextButton(new Vector2(UIScaler.GetRight(-5.5f), UIScaler.GetBottom(-2.5f)), new Vector2(5, 2), "Menu", delegate { Menu(); });
            qb.SetFont(game.gameType.GetHeaderFont());
        }
        else
        {
            qb = new TextButton(new Vector2(0.5f, UIScaler.GetBottom(-2.5f)), new Vector2(5, 2), "Menu", delegate { Menu(); });
            qb.SetFont(game.gameType.GetHeaderFont());
        }

        // Untag as dialog so this isn't cleared away
        qb.ApplyTag("questui");
    }
Ejemplo n.º 7
0
    public void About()
    {
        // This will destroy all, because we shouldn't have anything left at the main menu
        Destroyer.Destroy();

        // Name.  We should replace this with a banner
        DialogBox db = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 3), "Valkyrie");

        db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont();

        db = new DialogBox(new Vector2((UIScaler.GetWidthUnits() - 30f) / 2, 8f), new Vector2(30, 6), "Valkyrie is a game master helper tool inspired by Fantasy Flight Games' Descent: Road to Legend.  Most images used are imported from FFG applications are are copyright FFG and other rights holders.");
        db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();

        db = new DialogBox(new Vector2((UIScaler.GetWidthUnits() - 30f) / 2, 16f), new Vector2(30, 5), "Valkyrie uses DotNetZip-For-Unity and has code derived from Unity Studio.");
        db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();

        TextButton tb = new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), "Back", delegate { Destroyer.MainMenu(); });

        tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f);
    }
Ejemplo n.º 8
0
    // This is called when a quest is selected
    public void StartQuest(QuestData.Quest q)
    {
        if (Path.GetExtension(Path.GetFileName(q.path)) == ".valkyrie")
        {
            // extract the full package
            QuestLoader.ExtractSinglePackageFull(ContentData.DownloadPath() + Path.DirectorySeparatorChar + Path.GetFileName(q.path));
        }

        // Fetch all of the quest data and initialise the quest
        quest = new Quest(q);

        // Draw the hero icons, which are buttons for selection
        heroCanvas.SetupUI();

        // Add a finished button to start the quest
        UIElement ui = new UIElement(Game.HEROSELECT);

        ui.SetLocation(UIScaler.GetRight(-8.5f), UIScaler.GetBottom(-2.5f), 8, 2);
        ui.SetText(CommonStringKeys.FINISHED, Color.green);
        ui.SetFont(gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetButton(EndSelection);
        new UIElementBorder(ui, Color.green);

        // Add a title to the page
        ui = new UIElement(Game.HEROSELECT);
        ui.SetLocation(8, 1, UIScaler.GetWidthUnits() - 16, 3);
        ui.SetText(new StringKey("val", "SELECT", gameType.HeroesName()));
        ui.SetFont(gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetLargeFont());

        heroCanvas.heroSelection = new HeroSelection();

        ui = new UIElement(Game.HEROSELECT);
        ui.SetLocation(0.5f, UIScaler.GetBottom(-2.5f), 8, 2);
        ui.SetText(CommonStringKeys.BACK, Color.red);
        ui.SetFont(gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetButton(Destroyer.QuestSelect);
        new UIElementBorder(ui, Color.red);
    }
Ejemplo n.º 9
0
    public MenuButton()
    {
        Game game = Game.Get();

        UIElement ui = new UIElement(Game.QUESTUI);

        // For the editor button is moved to the right
        if (game.editMode)
        {
            ui.SetLocation(UIScaler.GetRight(-5.5f), UIScaler.GetBottom(-2.5f), 5, 2);
        }
        else
        {
            ui.SetLocation(UIScaler.GetRight(-5.5f), 0.5f, 5, 2);
        }
        ui.SetText(MENU);
        ui.SetFont(game.gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetButton(Menu);
        new UIElementBorder(ui);
    }
Ejemplo n.º 10
0
    public LogButton()
    {
        Game       game = Game.Get();
        TextButton qb;

        // For the editor button is moved to the right
        if (game.editMode)
        {
            return;
        }

        if (game.gameType is MoMGameType)
        {
            return;
        }

        qb = new TextButton(new Vector2(5.5f, UIScaler.GetBottom(-2.5f)), new Vector2(5, 2), "Log", delegate { Log(); });
        qb.SetFont(game.gameType.GetHeaderFont());
        // Untag as dialog so this isn't cleared away
        qb.ApplyTag("questui");
    }
Ejemplo n.º 11
0
    public InventoryButton()
    {
        Game       game = Game.Get();
        TextButton qb;

        // For the editor button is moved to the right
        if (game.editMode)
        {
            return;
        }

        if (game.gameType is MoMGameType)
        {
            return;
        }

        qb = new TextButton(new Vector2(15.5f, UIScaler.GetBottom(-2.5f)), new Vector2(5, 2), ITEMS, delegate { Items(); });
        qb.SetFont(game.gameType.GetHeaderFont());
        // Untag as dialog so this isn't cleared away
        qb.ApplyTag(Game.QUESTUI);
    }
Ejemplo n.º 12
0
    // This is called when a quest is selected
    public void StartQuest(QuestData.Quest q)
    {
        // Fetch all of the quest data and initialise the quest
        quest = new Quest(q);

        // Draw the hero icons, which are buttons for selection
        heroCanvas.SetupUI();

        // Add a finished button to start the quest
        TextButton endSelection = new TextButton(
            new Vector2(UIScaler.GetRight(-9),
                        UIScaler.GetBottom(-3)),
            new Vector2(8, 2),
            CommonStringKeys.FINISHED,
            delegate { EndSelection(); },
            Color.green);

        endSelection.SetFont(gameType.GetHeaderFont());
        // Untag as dialog so this isn't cleared away during hero selection
        endSelection.ApplyTag("heroselect");

        // Add a title to the page
        DialogBox db = new DialogBox(
            new Vector2(8, 1),
            new Vector2(UIScaler.GetWidthUnits() - 16, 3),
            new StringKey("val", "SELECT", gameType.HeroesName())
            );

        db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont();
        db.SetFont(gameType.GetHeaderFont());
        db.ApplyTag("heroselect");

        heroCanvas.heroSelection = new HeroSelection();

        TextButton cancelSelection = new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), CommonStringKeys.BACK, delegate { Destroyer.QuestSelect(); }, Color.red);

        cancelSelection.SetFont(gameType.GetHeaderFont());
        // Untag as dialog so this isn't cleared away during hero selection
        cancelSelection.ApplyTag("heroselect");
    }
Ejemplo n.º 13
0
        /// <summary>
        /// Method to create UI elements in the screen
        /// </summary>
        /// <param name="game">current game</param>
        private void CreateElements()
        {
            // Options screen text
            DialogBox dbTittle = new DialogBox(
                new Vector2(0, 1),
                new Vector2(UIScaler.GetWidthUnits() - 4, 3),
                OPTIONS
                );

            dbTittle.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont();
            dbTittle.SetFont(game.gameType.GetHeaderFont());

            CreateLanguageElements();

            CreateAudioElements();

            // Button for back to main menu
            TextButton tb = new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2),
                                           CommonStringKeys.BACK, delegate { Destroyer.MainMenu(); }, Color.red);

            tb.SetFont(game.gameType.GetHeaderFont());
        }
Ejemplo n.º 14
0
        // Create the about dialog
        public void About()
        {
            // This will destroy all, because we shouldn't have anything left at the main menu
            Destroyer.Destroy();

            Sprite    bannerSprite;
            Texture2D newTex = Resources.Load("sprites/banner") as Texture2D;

            GameObject banner = new GameObject("banner");

            banner.tag = "dialog";

            banner.transform.parent = Game.Get().uICanvas.transform;

            RectTransform trans = banner.AddComponent <RectTransform>();

            trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 1 * UIScaler.GetPixelsPerUnit(), 7f * UIScaler.GetPixelsPerUnit());
            trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, (UIScaler.GetWidthUnits() - 18f) * UIScaler.GetPixelsPerUnit() / 2f, 18f * UIScaler.GetPixelsPerUnit());
            banner.AddComponent <CanvasRenderer>();


            UnityEngine.UI.Image image = banner.AddComponent <UnityEngine.UI.Image>();
            bannerSprite = Sprite.Create(newTex, new Rect(0, 0, newTex.width, newTex.height), Vector2.zero, 1);
            image.sprite = bannerSprite;
            image.rectTransform.sizeDelta = new Vector2(18f * UIScaler.GetPixelsPerUnit(), 7f * UIScaler.GetPixelsPerUnit());

            DialogBox db = new DialogBox(new Vector2((UIScaler.GetWidthUnits() - 30f) / 2, 10f), new Vector2(30, 6), "Valkyrie is a game master helper tool inspired by Fantasy Flight Games' Descent: Road to Legend.  Most images used are imported from FFG applications are are copyright FFG and other rights holders.");

            db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();

            db = new DialogBox(new Vector2((UIScaler.GetWidthUnits() - 30f) / 2, 18f), new Vector2(30, 5), "Valkyrie uses DotNetZip-For-Unity and has code derived from Unity Studio and .NET Ogg Vorbis Encoder.");
            db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();

            TextButton tb = new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), "Back", delegate { Destroyer.MainMenu(); });

            tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f);
            tb.SetFont(Game.Get().gameType.GetHeaderFont());
        }
Ejemplo n.º 15
0
    public SkillButton()
    {
        Game game = Game.Get();

        if (game.editMode)
        {
            return;
        }

        if (game.gameType is MoMGameType)
        {
            return;
        }

        UIElement ui = new UIElement(Game.QUESTUI);

        ui.SetLocation(10.5f, UIScaler.GetBottom(-2.5f), 5, 2);
        ui.SetText(SKILLS);
        ui.SetFont(game.gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetButton(Skills);
        new UIElementBorder(ui);
    }
Ejemplo n.º 16
0
        /// <summary>
        /// Method to create UI elements in the screen
        /// </summary>
        /// <param name="game">current game</param>
        private void CreateElements()
        {
            // Options screen text
            UIElement ui = new UIElement();

            ui.SetLocation(2, 1, UIScaler.GetWidthUnits() - 4, 3);
            ui.SetText(OPTIONS);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetLargeFont());

            CreateLanguageElements();

            CreateAudioElements();

            // Button for back to main menu
            ui = new UIElement();
            ui.SetLocation(1, UIScaler.GetBottom(-3), 8, 2);
            ui.SetText(CommonStringKeys.BACK, Color.red);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(Destroyer.MainMenu);
            new UIElementBorder(ui, Color.red);
        }
Ejemplo n.º 17
0
    public InventoryButton()
    {
        Game game = Game.Get();

        // For the editor button is moved to the right
        if (game.editMode)
        {
            return;
        }

        if (game.gameType is MoMGameType)
        {
            return;
        }

        UIElement ui = new UIElement(Game.QUESTUI);

        ui.SetLocation(15.5f, UIScaler.GetBottom(-2.5f), 5, 2);
        ui.SetText(ITEMS);
        ui.SetFont(game.gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetButton(Items);
        new UIElementBorder(ui);
    }
Ejemplo n.º 18
0
    // Create a pack with list of quests to edit
    public QuestEditSelection()
    {
        Game game = Game.Get();

        // clear list of local quests to make sure we take the latest changes
        game.questsList.UnloadLocalQuests();

        // Get list of unpacked quest in user location (editable)
        // TODO: open/save in packages
        questList = QuestLoader.GetUserUnpackedQuests();

        // If a dialog window is open we force it closed (this shouldn't happen)
        foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.DIALOG))
        {
            Object.Destroy(go);
        }

        // Heading
        UIElement ui = new UIElement();

        ui.SetLocation(2, 1, UIScaler.GetWidthUnits() - 4, 3);
        ui.SetText(new StringKey("val", "SELECT", game.gameType.QuestName()));
        ui.SetFont(Game.Get().gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetLargeFont());

        UIElementScrollVertical scrollArea = new UIElementScrollVertical();

        scrollArea.SetLocation(1, 5, UIScaler.GetWidthUnits() - 2f, 21);
        new UIElementBorder(scrollArea);

        // List of quests
        int offset = 0;

        foreach (KeyValuePair <string, QuestData.Quest> q in questList)
        {
            string key = q.Key;
            LocalizationRead.AddDictionary("qst", q.Value.localizationDict);
            string translation = q.Value.name.Translate();

            ui = new UIElement(scrollArea.GetScrollTransform());
            ui.SetLocation(1, offset, UIScaler.GetWidthUnits() - 5, 1.2f);
            ui.SetText(new StringKey("val", "INDENT", translation), Color.black);
            ui.SetButton(delegate { Selection(key); });
            ui.SetBGColor(Color.white);
            offset += 2;
        }
        scrollArea.SetScrollSize(offset);

        // Main menu
        ui = new UIElement();
        ui.SetLocation(1, UIScaler.GetBottom(-3), 8, 2);
        ui.SetText(CommonStringKeys.BACK, Color.red);
        ui.SetFont(Game.Get().gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetButton(Cancel);
        new UIElementBorder(ui, Color.red);
        // Delete a user quest
        ui = new UIElement();
        ui.SetLocation((UIScaler.GetRight() * 3 / 8) - 4, UIScaler.GetBottom(-3), 8, 2);
        ui.SetText(CommonStringKeys.DELETE, Color.red);
        ui.SetFont(Game.Get().gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetButton(Delete);
        new UIElementBorder(ui, Color.red);
        // Copy a quest
        ui = new UIElement();
        ui.SetLocation((UIScaler.GetRight() * 5 / 8) - 4, UIScaler.GetBottom(-3), 8, 2);
        ui.SetText(CommonStringKeys.COPY);
        ui.SetFont(Game.Get().gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetButton(Copy);
        new UIElementBorder(ui);
        // Create a new quest
        ui = new UIElement();
        ui.SetLocation(UIScaler.GetRight(-9), UIScaler.GetBottom(-3), 8, 2);
        ui.SetText(CommonStringKeys.NEW);
        ui.SetFont(Game.Get().gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetButton(NewQuest);
        new UIElementBorder(ui);
    }
Ejemplo n.º 19
0
        public void Draw()
        {
            // This will destroy all
            Destroyer.Destroy();

            Game game = Game.Get();

            game.gameType = new NoGameType();

            // Get the current content for games
            if (Application.platform == RuntimePlatform.OSXPlayer)
            {
                fcD2E = new FFGImport(FFGAppImport.GameType.D2E, Platform.MacOS, Game.AppData() + "/", Application.isEditor);
                fcMoM = new FFGImport(FFGAppImport.GameType.MoM, Platform.MacOS, Game.AppData() + "/", Application.isEditor);
            }
            else if (Application.platform == RuntimePlatform.Android)
            {
                fcD2E = new FFGImport(FFGAppImport.GameType.D2E, Platform.Android, Game.AppData() + "/", Application.isEditor);
                fcMoM = new FFGImport(FFGAppImport.GameType.MoM, Platform.Android, Game.AppData() + "/", Application.isEditor);
            }
            else
            {
                fcD2E = new FFGImport(FFGAppImport.GameType.D2E, Platform.Windows, Game.AppData() + "/", Application.isEditor);
                fcMoM = new FFGImport(FFGAppImport.GameType.MoM, Platform.Windows, Game.AppData() + "/", Application.isEditor);
            }

            fcD2E.Inspect();
            fcMoM.Inspect();

            // Banner Image
            Sprite    bannerSprite;
            Texture2D newTex = Resources.Load("sprites/banner") as Texture2D;

            GameObject banner = new GameObject("banner");

            banner.tag = Game.DIALOG;

            banner.transform.SetParent(game.uICanvas.transform);

            RectTransform trans = banner.AddComponent <RectTransform>();

            trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 1 * UIScaler.GetPixelsPerUnit(), 7f * UIScaler.GetPixelsPerUnit());
            trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, (UIScaler.GetWidthUnits() - 18f) * UIScaler.GetPixelsPerUnit() / 2f, 18f * UIScaler.GetPixelsPerUnit());
            banner.AddComponent <CanvasRenderer>();


            UnityEngine.UI.Image image = banner.AddComponent <UnityEngine.UI.Image>();
            bannerSprite = Sprite.Create(newTex, new Rect(0, 0, newTex.width, newTex.height), Vector2.zero, 1);
            image.sprite = bannerSprite;
            image.rectTransform.sizeDelta = new Vector2(18f * UIScaler.GetPixelsPerUnit(), 7f * UIScaler.GetPixelsPerUnit());

            Color startColor = Color.white;

            // If we need to import we can't play this type
            if (fcD2E.NeedImport())
            {
                startColor = Color.gray;
            }
            // Draw D2E button
            UIElement ui = new UIElement();

            ui.SetLocation((UIScaler.GetWidthUnits() - 30) / 2, 10, 30, 4);
            ui.SetText(D2E_NAME, startColor);
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(delegate { D2E(); });
            ui.SetBGColor(new Color(0, 0.03f, 0f));
            new UIElementBorder(ui, startColor);

            // Draw D2E import button
            ui = new UIElement();
            if (fcD2E.ImportAvailable())
            {
                ui.SetLocation((UIScaler.GetWidthUnits() - 14) / 2, 14.2f, 14, 2);
                StringKey keyText = fcD2E.NeedImport() ? CONTENT_IMPORT : CONTENT_REIMPORT;
                ui.SetText(keyText);
                ui.SetFontSize(UIScaler.GetMediumFont());
                ui.SetButton(delegate { Import("D2E"); });
                ui.SetBGColor(new Color(0, 0.03f, 0f));
                new UIElementBorder(ui);
            }
            else // Import unavailable
            {
                ui.SetLocation((UIScaler.GetWidthUnits() - 24) / 2, 14.2f, 24, 1);
                ui.SetText(D2E_APP_NOT_FOUND, Color.red);
                new UIElementBorder(ui, Color.red);
            }

            // Draw MoM button
            startColor = Color.white;
            if (fcMoM.NeedImport())
            {
                startColor = Color.gray;
            }
            ui = new UIElement();
            ui.SetLocation((UIScaler.GetWidthUnits() - 30) / 2, 19, 30, 4);
            ui.SetText(MOM_NAME, startColor);
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(delegate { MoM(); });
            ui.SetBGColor(new Color(0, 0.03f, 0f));
            new UIElementBorder(ui, startColor);

            // Draw MoM import button
            ui = new UIElement();
            if (fcMoM.ImportAvailable())
            {
                ui.SetLocation((UIScaler.GetWidthUnits() - 14) / 2, 23.2f, 14, 2);
                StringKey keyText = fcMoM.NeedImport() ? CONTENT_IMPORT : CONTENT_REIMPORT;
                ui.SetText(keyText);
                ui.SetFontSize(UIScaler.GetMediumFont());
                ui.SetButton(delegate { Import("MoM"); });
                ui.SetBGColor(new Color(0, 0.03f, 0f));
                new UIElementBorder(ui);
            }
            else // Import unavailable
            {
                ui.SetLocation((UIScaler.GetWidthUnits() - 24) / 2, 23.2f, 24, 1);
                ui.SetText(MOM_APP_NOT_FOUND, Color.red);
                new UIElementBorder(ui, Color.red);
            }

            ui = new UIElement();
            ui.SetLocation(1, UIScaler.GetBottom(-3), 8, 2);
            ui.SetText(CommonStringKeys.EXIT, Color.red);
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(Exit);
            ui.SetBGColor(new Color(0, 0.03f, 0f));
            new UIElementBorder(ui, Color.red);
        }
Ejemplo n.º 20
0
        public QuestSelectionScreen(Dictionary <string, QuestData.Quest> ql)
        {
            questList = ql;
            Game game = Game.Get();

            // If a dialog window is open we force it closed (this shouldn't happen)
            foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.DIALOG))
            {
                Object.Destroy(go);
            }

            // Clean up downloader if present
            foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.QUESTUI))
            {
                Object.Destroy(go);
            }

            // Heading
            UIElement ui = new UIElement();

            ui.SetLocation(2, 1, UIScaler.GetWidthUnits() - 4, 3);
            ui.SetText(new StringKey("val", "SELECT", game.gameType.QuestName()));
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetLargeFont());

            UIElementScrollVertical scrollArea = new UIElementScrollVertical();

            scrollArea.SetLocation(1, 5, UIScaler.GetWidthUnits() - 2f, 21f);
            new UIElementBorder(scrollArea);

            // Start here
            float offset = 0;

            // Loop through all available quests
            foreach (KeyValuePair <string, QuestData.Quest> q in questList)
            {
                if (q.Value.GetMissingPacks(game.cd.GetLoadedPackIDs()).Count == 0)
                {
                    string key = q.Key;
                    LocalizationRead.scenarioDict = q.Value.localizationDict;
                    string translation = q.Value.name.Translate();

                    // Frame
                    ui = new UIElement(scrollArea.GetScrollTransform());
                    ui.SetLocation(0.95f, offset, UIScaler.GetWidthUnits() - 4.9f, 3.1f);
                    ui.SetBGColor(Color.white);
                    ui.SetButton(delegate { Selection(key); });
                    offset += 0.05f;

                    // Draw Image
                    ui = new UIElement(scrollArea.GetScrollTransform());
                    ui.SetLocation(1, offset, 3, 3);
                    ui.SetBGColor(Color.white);
                    ui.SetButton(delegate { Selection(key); });
                    if (q.Value.image.Length > 0)
                    {
                        ui.SetImage(ContentData.FileToTexture(Path.Combine(q.Value.path, q.Value.image)));
                    }

                    ui = new UIElement(scrollArea.GetScrollTransform());
                    ui.SetBGColor(Color.clear);
                    ui.SetLocation(4, offset, UIScaler.GetWidthUnits() - 8, 3f);
                    ui.SetTextPadding(1.2f);
                    ui.SetText(translation, Color.black);
                    ui.SetButton(delegate { Selection(key); });
                    ui.SetTextAlignment(TextAnchor.MiddleLeft);
                    ui.SetFontSize(Mathf.RoundToInt(UIScaler.GetSmallFont() * 1.3f));

                    // Duration
                    if (q.Value.lengthMax != 0)
                    {
                        ui = new UIElement(scrollArea.GetScrollTransform());
                        ui.SetLocation(UIScaler.GetRight(-11), offset, 2, 1);
                        ui.SetText(q.Value.lengthMin.ToString(), Color.black);
                        ui.SetButton(delegate { Selection(key); });
                        ui.SetBGColor(Color.clear);

                        ui = new UIElement(scrollArea.GetScrollTransform());
                        ui.SetLocation(UIScaler.GetRight(-9), offset, 1, 1);
                        ui.SetButton(delegate { Selection(key); });
                        ui.SetText("-", Color.black);
                        ui.SetBGColor(Color.clear);

                        ui = new UIElement(scrollArea.GetScrollTransform());
                        ui.SetLocation(UIScaler.GetRight(-8), offset, 2, 1);
                        ui.SetText(q.Value.lengthMax.ToString(), Color.black);
                        ui.SetButton(delegate { Selection(key); });
                        ui.SetBGColor(Color.clear);
                    }

                    // Difficulty
                    if (q.Value.difficulty != 0)
                    {
                        string symbol = "π"; // will
                        if (game.gameType is MoMGameType)
                        {
                            symbol = new StringKey("val", "ICON_SUCCESS_RESULT").Translate();
                        }
                        ui = new UIElement(scrollArea.GetScrollTransform());
                        ui.SetLocation(UIScaler.GetRight(-12), offset + 1, 7, 2);
                        ui.SetText(symbol + symbol + symbol + symbol + symbol, Color.black);
                        ui.SetBGColor(Color.clear);
                        ui.SetFontSize(UIScaler.GetMediumFont());
                        ui.SetButton(delegate { Selection(key); });

                        ui = new UIElement(scrollArea.GetScrollTransform());
                        ui.SetLocation(UIScaler.GetRight(-11.95f) + (q.Value.difficulty * 6.9f), offset + 1, (1 - q.Value.difficulty) * 6.9f, 2);
                        ui.SetBGColor(new Color(1, 1, 1, 0.7f));
                        ui.SetButton(delegate { Selection(key); });
                    }

                    offset += 4;
                }
            }

            // Loop through all unavailable quests
            foreach (KeyValuePair <string, QuestData.Quest> q in questList)
            {
                if (q.Value.GetMissingPacks(game.cd.GetLoadedPackIDs()).Count > 0)
                {
                    string key = q.Key;
                    LocalizationRead.scenarioDict = q.Value.localizationDict;
                    string translation = q.Value.name.Translate();

                    // Size is 1.2 to be clear of characters with tails
                    ui = new UIElement(scrollArea.GetScrollTransform());
                    ui.SetLocation(1, offset, UIScaler.GetWidthUnits() - 5, 1.2f);
                    ui.SetText(new StringKey("val", "INDENT", translation), Color.black);
                    ui.SetTextAlignment(TextAnchor.MiddleLeft);
                    ui.SetBGColor(new Color(0.4f, 0.4f, 0.4f));
                    offset += 1.2f;

                    foreach (string s in q.Value.GetMissingPacks(game.cd.GetLoadedPackIDs()))
                    {
                        ui = new UIElement(scrollArea.GetScrollTransform());
                        ui.SetLocation(3, offset, UIScaler.GetWidthUnits() - 9, 1.2f);
                        ui.SetText(new StringKey("val", "REQUIRES_EXPANSION", game.cd.GetContentName(s)), Color.black);
                        ui.SetTextAlignment(TextAnchor.MiddleLeft);
                        ui.SetBGColor(new Color(0.4f, 0.4f, 0.4f));
                        offset += 1.2f;
                    }
                }
                offset += 0.8f;
            }

            scrollArea.SetScrollSize(offset);

            ui = new UIElement();
            ui.SetLocation(1, UIScaler.GetBottom(-3), 8, 2);
            ui.SetText(CommonStringKeys.BACK, Color.red);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(delegate { Cancel(); });
            new UIElementBorder(ui, Color.red);

            ui = new UIElement();
            ui.SetLocation(UIScaler.GetRight(-9), UIScaler.GetBottom(-3), 8, 2);
            ui.SetText(DOWNLOAD, Color.green);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(delegate { Download(); });
            new UIElementBorder(ui, Color.green);
        }
Ejemplo n.º 21
0
    // Create a menu which will take up the whole screen and have options.  All items are dialog for destruction.
    public GameSelection()
    {
        // This will destroy all
        Destroyer.Destroy();

        Game game = Game.Get();

        game.gameType = new NoGameType();

        fcD2E = new FetchContent("D2E");
        fcMoM = new FetchContent("MoM");

        // Name.  We should replace this with a banner
        DialogBox db = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 3), "Valkyrie");

        db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont();

        Color startColor = Color.white;

        if (fcD2E.NeedImport())
        {
            startColor = Color.gray;
        }
        TextButton tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 30) / 2, 10), new Vector2(30, 4f), "Descent: Journeys in the Dark Second Edition", delegate { D2E(); }, startColor);

        tb.button.GetComponent <UnityEngine.UI.Text>().fontSize   = UIScaler.GetMediumFont();
        tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f);

        if (fcD2E.importAvailable)
        {
            if (fcD2E.NeedImport())
            {
                tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 14.2f), new Vector2(10, 2f), "Import Content", delegate { Import("D2E"); });
                tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f);
            }
            else
            {
                tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 14.2f), new Vector2(10, 2f), "Reimport Content", delegate { Import("D2E"); });
                tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f);
            }
        }
        else
        {
            db = new DialogBox(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 14.2f), new Vector2(10, 2f), "Import Unavailable", Color.red);
            db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();
            db.AddBorder();
        }

        startColor = Color.white;
        if (fcMoM.NeedImport())
        {
            startColor = Color.gray;
        }
        tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 30) / 2, 19), new Vector2(30, 4f), "Mansions of Madness Second Edition", delegate { MoM(); }, startColor);
        tb.button.GetComponent <UnityEngine.UI.Text>().fontSize   = UIScaler.GetMediumFont();
        tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f);

        if (fcMoM.importAvailable)
        {
            if (fcMoM.NeedImport())
            {
                tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 23.2f), new Vector2(10, 2f), "Import Content", delegate { Import("MoM"); });
                tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f);
            }
            else
            {
                tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 23.2f), new Vector2(10, 2f), "Reimport Content", delegate { Import("MoM"); });
                tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f);
            }
        }
        else
        {
            db = new DialogBox(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 23.2f), new Vector2(10, 2f), "Import Unavailable", Color.red);
            db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();
            db.AddBorder();
        }
        new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), "Exit", delegate { Exit(); }, Color.red);
    }
Ejemplo n.º 22
0
    public void Update()
    {
        // Clean up everything marked as 'uiphase'
        foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.UIPHASE))
        {
            Object.Destroy(go);
        }

        Color     bgColor = new Color(0.05f, 0, 0, 0.9f);
        StringKey phase;

        if (Game.Get().quest.phase == Quest.MoMPhase.horror)
        {
            phase = HORROR_STEP;
        }
        else if (Game.Get().quest.phase == Quest.MoMPhase.mythos)
        {
            phase = PHASE_MYTHOS;
        }
        else if (Game.Get().quest.phase == Quest.MoMPhase.monsters)
        {
            phase = MONSTER_STEP;
        }
        else
        {
            phase   = PHASE_INVESTIGATOR;
            bgColor = new Color(0, 0.05f, 0, 0.9f);
        }

        TextButton tb = new TextButton(
            new Vector2(UIScaler.GetHCenter(12f), UIScaler.GetBottom(-2.5f)), new Vector2(4, 2),
            CommonStringKeys.TAB, delegate { Next(); });

        // Untag as dialog so this isn't cleared away
        tb.ApplyTag(Game.UIPHASE);
        tb.background.GetComponent <UnityEngine.UI.Image>().color = bgColor;
        tb.SetFont(Game.Get().gameType.GetHeaderFont());

        tb = new TextButton(
            new Vector2(UIScaler.GetHCenter(-16f), UIScaler.GetBottom(-2.5f)), new Vector2(4, 2),
            new StringKey("val", "ITEMS"), delegate { Items(); });
        // Untag as dialog so this isn't cleared away
        tb.ApplyTag(Game.UIPHASE);
        tb.background.GetComponent <UnityEngine.UI.Image>().color = bgColor;
        tb.SetFont(Game.Get().gameType.GetHeaderFont());

        tb = new TextButton(
            new Vector2(UIScaler.GetHCenter(-12f), UIScaler.GetBottom(-2.5f)), new Vector2(4, 2),
            CommonStringKeys.LOG, delegate { Log(); });
        // Untag as dialog so this isn't cleared away
        tb.ApplyTag(Game.UIPHASE);
        tb.background.GetComponent <UnityEngine.UI.Image>().color = bgColor;
        tb.SetFont(Game.Get().gameType.GetHeaderFont());

        tb = new TextButton(
            new Vector2(UIScaler.GetHCenter(-8f), UIScaler.GetBottom(-2.5f)), new Vector2(4, 2),
            CommonStringKeys.SET, delegate { Set(); });
        // Untag as dialog so this isn't cleared away
        tb.ApplyTag(Game.UIPHASE);
        tb.background.GetComponent <UnityEngine.UI.Image>().color = bgColor;
        tb.SetFont(Game.Get().gameType.GetHeaderFont());

        DialogBox db;

        db = new DialogBox(new Vector2(UIScaler.GetHCenter(-4f), UIScaler.GetBottom(-2.5f)), new Vector2(16, 2), phase, Color.white, bgColor);
        db.SetFont(Game.Get().gameType.GetHeaderFont());
        db.ApplyTag(Game.UIPHASE);
        db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();
        db.AddBorder();
    }
Ejemplo n.º 23
0
    // Create a menu which will take up the whole screen and have options.  All items are dialog for destruction.
    public GameSelection()
    {
        // This will destroy all
        Destroyer.Destroy();

        Game game = Game.Get();

        game.gameType = new NoGameType();

        // Get the current content for games
        fcD2E = new FetchContent("D2E");
        fcMoM = new FetchContent("MoM");

        // Banner Image
        Sprite    bannerSprite;
        Texture2D newTex = Resources.Load("sprites/banner") as Texture2D;

        GameObject banner = new GameObject("banner");

        banner.tag = "dialog";

        banner.transform.parent = game.uICanvas.transform;

        RectTransform trans = banner.AddComponent <RectTransform>();

        trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 1 * UIScaler.GetPixelsPerUnit(), 7f * UIScaler.GetPixelsPerUnit());
        trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, (UIScaler.GetWidthUnits() - 18f) * UIScaler.GetPixelsPerUnit() / 2f, 18f * UIScaler.GetPixelsPerUnit());
        banner.AddComponent <CanvasRenderer>();


        UnityEngine.UI.Image image = banner.AddComponent <UnityEngine.UI.Image>();
        bannerSprite = Sprite.Create(newTex, new Rect(0, 0, newTex.width, newTex.height), Vector2.zero, 1);
        image.sprite = bannerSprite;
        image.rectTransform.sizeDelta = new Vector2(18f * UIScaler.GetPixelsPerUnit(), 7f * UIScaler.GetPixelsPerUnit());

        DialogBox db;

        Color startColor = Color.white;

        // If we need to import we can't play this type
        if (fcD2E.NeedImport())
        {
            startColor = Color.gray;
        }
        // Draw D2E button
        TextButton tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 30) / 2, 10), new Vector2(30, 4f), "Descent: Journeys in the Dark Second Edition", delegate { D2E(); }, startColor);

        tb.button.GetComponent <UnityEngine.UI.Text>().fontSize   = UIScaler.GetMediumFont();
        tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f);

        // Draw D2E import button
        if (fcD2E.importAvailable)
        {
            if (fcD2E.NeedImport())
            {
                tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 14.2f), new Vector2(10, 2f), "Import Content", delegate { Import("D2E"); });
                tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f);
            }
            else // Import OK, can redo
            {
                tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 14.2f), new Vector2(10, 2f), "Reimport Content", delegate { Import("D2E"); });
                tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f);
            }
        }
        else // Import unavailable
        {
            db = new DialogBox(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 14.2f), new Vector2(10, 2f), "Import Unavailable", Color.red);
            db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();
            db.AddBorder();
        }

        // Draw MoM button
        startColor = Color.white;
        if (fcMoM.NeedImport())
        {
            startColor = Color.gray;
        }
        tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 30) / 2, 19), new Vector2(30, 4f), "Mansions of Madness Second Edition", delegate { MoM(); }, startColor);
        tb.button.GetComponent <UnityEngine.UI.Text>().fontSize   = UIScaler.GetMediumFont();
        tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f);

        // Draw MoM import button
        if (fcMoM.importAvailable)
        {
            if (fcMoM.NeedImport())
            {
                tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 23.2f), new Vector2(10, 2f), "Import Content", delegate { Import("MoM"); });
                tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f);
            }
            else // Import OK, can redo
            {
                tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 23.2f), new Vector2(10, 2f), "Reimport Content", delegate { Import("MoM"); });
                tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f);
            }
        }
        else // Import unavailable
        {
            db = new DialogBox(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 23.2f), new Vector2(10, 2f), "Import Unavailable", Color.red);
            db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();
            db.AddBorder();
        }
        new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), "Exit", delegate { Exit(); }, Color.red);
    }
Ejemplo n.º 24
0
        private void CreateElements()
        {
            float     offset = 1f;
            UIElement ui     = null;

            if (save)
            {
                offset += 2;
                ui      = new UIElement();
                ui.SetLocation(UIScaler.GetHCenter(-21), offset, 42, 24);
                offset += 1;
            }
            ui = new UIElement();
            ui.SetLocation(UIScaler.GetHCenter(-10), offset, 20, 3);
            ui.SetText(SELECT_SAVE);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetLargeFont());

            offset += 4;
            for (int i = 0; i < saves.Count; i++)
            {
                if (i == 0 && save)
                {
                    continue;
                }

                int tmp = i;
                if (saves[i].valid)
                {
                    string name = SAVE.Translate() + " " + i;
                    if (i == 0)
                    {
                        name = AUTOSAVE.Translate();
                    }

                    ui = new UIElement();
                    ui.SetLocation(UIScaler.GetHCenter(-20), offset, 40, 4);
                    ui.SetButton(delegate { Select(tmp); });
                    new UIElementBorder(ui);

                    if (saves[i].image != null)
                    {
                        Sprite imgSprite = Sprite.Create(saves[i].image, new Rect(0, 0, saves[i].image.width, saves[i].image.height), Vector2.zero, 1, 0, SpriteMeshType.FullRect);
                        ui = new UIElement();
                        ui.SetLocation(UIScaler.GetHCenter(-20), offset, 4f * (float)saves[i].image.width / (float)saves[i].image.height, 4);
                        ui.SetButton(delegate { Select(tmp); });
                        ui.SetImage(imgSprite);
                        new UIElementBorder(ui);
                    }

                    ui = new UIElement();
                    ui.SetLocation(UIScaler.GetHCenter(-12), offset + 0.5f, 10, 2);
                    ui.SetText(name);
                    ui.SetTextAlignment(TextAnchor.MiddleLeft);
                    ui.SetFontSize(UIScaler.GetMediumFont());
                    ui.SetButton(delegate { Select(tmp); });

                    ui = new UIElement();
                    ui.SetLocation(UIScaler.GetHCenter(-1), offset + 0.5f, 20, 2);
                    ui.SetText(saves[i].saveTime.ToString());
                    ui.SetTextAlignment(TextAnchor.MiddleRight);
                    ui.SetFontSize(UIScaler.GetMediumFont());
                    ui.SetButton(delegate { Select(tmp); });

                    ui = new UIElement();
                    ui.SetLocation(UIScaler.GetHCenter(-12), offset + 2.6f, 31, 1);
                    ui.SetText(saves[i].quest_name);
                    ui.SetTextAlignment(TextAnchor.MiddleLeft);
                    ui.SetButton(delegate { Select(tmp); });
                }
                else
                {
                    ui = new UIElement();
                    ui.SetLocation(UIScaler.GetHCenter(-20), offset, 40, 4);
                    ui.SetButton(delegate { Select(tmp); });
                    new UIElementBorder(ui, Color.gray);
                }
                offset += 5;
            }

            if (save)
            {
                // Button for cancel
                ui = new UIElement();
                ui.SetLocation(UIScaler.GetHCenter(-4), 24, 8, 2);
                ui.SetText(CommonStringKeys.CANCEL);
                ui.SetFontSize(UIScaler.GetMediumFont());
                ui.SetButton(Destroyer.Dialog);
                new UIElementBorder(ui);
            }
            else
            {
                // Button for back to main menu
                ui = new UIElement();
                ui.SetLocation(1, UIScaler.GetBottom(-3), 8, 2);
                ui.SetText(CommonStringKeys.BACK, Color.red);
                ui.SetFontSize(UIScaler.GetMediumFont());
                ui.SetButton(GameStateManager.MainMenu);
                new UIElementBorder(ui, Color.red);
            }
            ui.SetFont(game.gameType.GetHeaderFont());
        }
Ejemplo n.º 25
0
        public void Draw()
        {
            // This will destroy all
            Destroyer.Destroy();

            Game game = Game.Get();

            game.gameType = new NoGameType();

            // Get the current content for games
            if (Application.platform == RuntimePlatform.OSXPlayer)
            {
                fcD2E = new FFGImport(FFGAppImport.GameType.D2E, Platform.MacOS, ContentData.ContentPath(), Application.isEditor);
                fcMoM = new FFGImport(FFGAppImport.GameType.MoM, Platform.MacOS, ContentData.ContentPath(), Application.isEditor);
            }
            else
            {
                fcD2E = new FFGImport(FFGAppImport.GameType.D2E, Platform.Windows, ContentData.ContentPath(), Application.isEditor);
                fcMoM = new FFGImport(FFGAppImport.GameType.MoM, Platform.Windows, ContentData.ContentPath(), Application.isEditor);
            }

            fcD2E.Inspect();
            fcMoM.Inspect();

            // Banner Image
            Sprite    bannerSprite;
            Texture2D newTex = Resources.Load("sprites/banner") as Texture2D;

            GameObject banner = new GameObject("banner");

            banner.tag = Game.DIALOG;

            banner.transform.SetParent(game.uICanvas.transform);

            RectTransform trans = banner.AddComponent <RectTransform>();

            trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 1 * UIScaler.GetPixelsPerUnit(), 7f * UIScaler.GetPixelsPerUnit());
            trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, (UIScaler.GetWidthUnits() - 18f) * UIScaler.GetPixelsPerUnit() / 2f, 18f * UIScaler.GetPixelsPerUnit());
            banner.AddComponent <CanvasRenderer>();


            UnityEngine.UI.Image image = banner.AddComponent <UnityEngine.UI.Image>();
            bannerSprite = Sprite.Create(newTex, new Rect(0, 0, newTex.width, newTex.height), Vector2.zero, 1);
            image.sprite = bannerSprite;
            image.rectTransform.sizeDelta = new Vector2(18f * UIScaler.GetPixelsPerUnit(), 7f * UIScaler.GetPixelsPerUnit());

            DialogBox db;

            Color startColor = Color.white;

            // If we need to import we can't play this type
            if (fcD2E.NeedImport())
            {
                startColor = Color.gray;
            }
            // Draw D2E button
            TextButton tb = new TextButton(
                new Vector2((UIScaler.GetWidthUnits() - 30) / 2, 10),
                new Vector2(30, 4f),
                D2E_NAME,
                delegate { D2E(); },
                startColor);

            tb.button.GetComponent <UnityEngine.UI.Text>().fontSize   = UIScaler.GetMediumFont();
            tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f);

            // Draw D2E import button
            if (fcD2E.ImportAvailable())
            {
                StringKey keyText = fcD2E.NeedImport() ? CONTENT_IMPORT : CONTENT_REIMPORT;
                tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 14.2f), new Vector2(10, 2f), keyText, delegate { Import("D2E"); });
                tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f);
            }
            else // Import unavailable
            {
                db = new DialogBox(new Vector2((UIScaler.GetWidthUnits() - 24) / 2, 14.2f), new Vector2(24, 1f), D2E_APP_NOT_FOUND, Color.red);
                db.AddBorder();
            }

            // Draw MoM button
            startColor = Color.white;
            if (fcMoM.NeedImport())
            {
                startColor = Color.gray;
            }
            tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 30) / 2, 19), new Vector2(30, 4f), MOM_NAME, delegate { MoM(); }, startColor);
            tb.button.GetComponent <UnityEngine.UI.Text>().fontSize   = UIScaler.GetMediumFont();
            tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f);

            // Draw MoM import button
            if (fcMoM.ImportAvailable())
            {
                StringKey keyText = fcMoM.NeedImport() ? CONTENT_IMPORT : CONTENT_REIMPORT;
                tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 23.2f), new Vector2(10, 2f), keyText, delegate { Import("MoM"); });
                tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f);
            }
            else // Import unavailable
            {
                db = new DialogBox(new Vector2((UIScaler.GetWidthUnits() - 24) / 2, 23.2f), new Vector2(24, 1f), MOM_APP_NOT_FOUND, Color.red);
                db.AddBorder();
            }

            new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), CommonStringKeys.EXIT, delegate { Exit(); }, Color.red);
        }
Ejemplo n.º 26
0
        public void Draw()
        {
            // This will destroy all
            Destroyer.Destroy();

            Game game = Game.Get();

            game.gameType = new NoGameType();

            // Get the current content for games
            if (Application.platform == RuntimePlatform.OSXPlayer)
            {
                fcD2E = new FFGImport(FFGAppImport.GameType.D2E, Platform.MacOS, Game.AppData() + Path.DirectorySeparatorChar, Application.isEditor);
                fcMoM = new FFGImport(FFGAppImport.GameType.MoM, Platform.MacOS, Game.AppData() + Path.DirectorySeparatorChar, Application.isEditor);
#if IA
                fcIA = new FFGImport(FFGAppImport.GameType.IA, Platform.MacOS, Game.AppData() + Path.DirectorySeparatorChar, Application.isEditor);
#endif
            }
            else if (Application.platform == RuntimePlatform.Android)
            {
                fcD2E = new FFGImport(FFGAppImport.GameType.D2E, Platform.Android, Game.AppData() + Path.DirectorySeparatorChar, Application.isEditor);
                fcMoM = new FFGImport(FFGAppImport.GameType.MoM, Platform.Android, Game.AppData() + Path.DirectorySeparatorChar, Application.isEditor);
#if IA
                fcIA = new FFGImport(FFGAppImport.GameType.IA, Platform.Android, Game.AppData() + Path.DirectorySeparatorChar, Application.isEditor);
#endif
            }
            else
            {
                fcD2E = new FFGImport(FFGAppImport.GameType.D2E, Platform.Windows, Game.AppData() + Path.DirectorySeparatorChar, Application.isEditor);
                fcMoM = new FFGImport(FFGAppImport.GameType.MoM, Platform.Windows, Game.AppData() + Path.DirectorySeparatorChar, Application.isEditor);
#if IA
                fcIA = new FFGImport(FFGAppImport.GameType.IA, Platform.Windows, Game.AppData() + Path.DirectorySeparatorChar, Application.isEditor);
#endif
            }

            fcD2E.Inspect();
            fcMoM.Inspect();
#if IA
            fcIA.Inspect();
#endif

            // Banner Image
            Sprite    bannerSprite;
            Texture2D newTex = Resources.Load("sprites/banner") as Texture2D;

            GameObject banner = new GameObject("banner");
            banner.tag = Game.DIALOG;

            banner.transform.SetParent(game.uICanvas.transform);

            RectTransform trans = banner.AddComponent <RectTransform>();
            trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 1 * UIScaler.GetPixelsPerUnit(), 7f * UIScaler.GetPixelsPerUnit());
            trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, (UIScaler.GetWidthUnits() - 18f) * UIScaler.GetPixelsPerUnit() / 2f, 18f * UIScaler.GetPixelsPerUnit());
            banner.AddComponent <CanvasRenderer>();


            UnityEngine.UI.Image image = banner.AddComponent <UnityEngine.UI.Image>();
            bannerSprite = Sprite.Create(newTex, new Rect(0, 0, newTex.width, newTex.height), Vector2.zero, 1);
            image.sprite = bannerSprite;
            image.rectTransform.sizeDelta = new Vector2(18f * UIScaler.GetPixelsPerUnit(), 7f * UIScaler.GetPixelsPerUnit());

            // first button y offset
            float offset = 12f;

            // Draw D2E button
            bool  D2E_need_import      = fcD2E.NeedImport();
            bool  D2E_import_available = fcD2E.ImportAvailable();
            Color startColor           = D2E_need_import ? Color.grey : Color.white;
            int   fontSize             = UIScaler.GetMediumFont();

            UIElement ui = new UIElement();
            ui.SetLocation((UIScaler.GetWidthUnits() - 30) / 2, offset, 30, 3);
            // If we need to import we can't play this type
            if (!D2E_need_import)
            {
                ui.SetText(D2E_NAME, startColor);
                ui.SetButton(delegate { D2E(); });
            }
            else
            {
                string message = "";
                if (D2E_import_available)
                {
                    message = D2E_NAME.Translate();
                }
                else
                {
                    message  = D2E_NAME.Translate() + System.Environment.NewLine + D2E_APP_NOT_FOUND.Translate();
                    fontSize = (int)(UIScaler.GetMediumFont() / 1.05f);
                }
                ui.SetText(message, startColor);
            }
            ui.SetFontSize(fontSize);
            ui.SetBGColor(new Color(0, 0.03f, 0f));
            new UIElementBorder(ui, startColor);

            // Draw D2E import button
            ui = new UIElement();
            if (D2E_import_available || !D2E_need_import)
            {
                ui.SetLocation((UIScaler.GetWidthUnits() - 14) / 2, offset + 3.2f, 14, 2);
                StringKey keyText = D2E_need_import ? CONTENT_IMPORT : CONTENT_REIMPORT;
                ui.SetText(keyText);
                ui.SetFontSize(UIScaler.GetMediumFont());
                ui.SetButton(delegate { Import("D2E", !D2E_import_available); });
                ui.SetBGColor(new Color(0, 0.03f, 0f));
                new UIElementBorder(ui);
            }
            else // Import unavailable
            {
                // only install button for Android
                if (Application.platform == RuntimePlatform.Android)
                {
                    ui = new UIElement();
                    ui.SetLocation((UIScaler.GetWidthUnits() - 24) / 2, offset + 3.2f, 24, 1.3f);
                    ui.SetText(CONTENT_INSTALL_VIA_GOOGLEPLAY, Color.red);
                    ui.SetButton(delegate { GotoWebBrowser(D2E_APP_URL_ANDROID); });
                    new UIElementBorder(ui, Color.red);
                }
                else
                {
                    // install and locate button for other systems
                    ui = new UIElement();
                    ui.SetLocation((UIScaler.GetWidthUnits() / 2) - 13, offset + 3.2f, 12, 1.3f);
                    ui.SetText(CONTENT_INSTALL_VIA_STEAM, Color.red);
                    ui.SetButton(delegate { GotoWebBrowser(D2E_APP_URL_STEAM); });
                    new UIElementBorder(ui, Color.red);

                    ui = new UIElement();
                    ui.SetLocation((UIScaler.GetWidthUnits() / 2) + 1, offset + 3.2f, 12, 1.3f);
                    ui.SetText(CONTENT_LOCATE, Color.red);
                    ui.SetButton(delegate { Import("D2E", true); });
                    new UIElementBorder(ui, Color.red);
                }
            }

            offset += 7f;

            // Draw MoM button
            bool MoM_need_import      = fcMoM.NeedImport();
            bool MoM_import_available = fcMoM.ImportAvailable();
            startColor = MoM_need_import ? Color.grey : Color.white;
            fontSize   = UIScaler.GetMediumFont();

            ui = new UIElement();
            ui.SetLocation((UIScaler.GetWidthUnits() - 30) / 2, offset, 30, 3);
            // If we need to import we can't play this type
            if (!MoM_need_import)
            {
                ui.SetText(MOM_NAME, startColor);
                ui.SetButton(delegate { MoM(); });
            }
            else
            {
                string message = "";
                if (MoM_import_available)
                {
                    message = MOM_NAME.Translate();
                }
                else
                {
                    message  = MOM_NAME.Translate() + System.Environment.NewLine + MOM_APP_NOT_FOUND.Translate();
                    fontSize = (int)(UIScaler.GetMediumFont() / 1.05f);
                }
                ui.SetText(message, startColor);
            }
            ui.SetFontSize(fontSize);
            ui.SetBGColor(new Color(0, 0.03f, 0f));
            new UIElementBorder(ui, startColor);

            // Draw MoM import button
            ui = new UIElement();
            if (MoM_import_available || !MoM_need_import)
            {
                ui.SetLocation((UIScaler.GetWidthUnits() - 14) / 2, offset + 3.2f, 14, 2);
                StringKey keyText = MoM_need_import ? CONTENT_IMPORT : CONTENT_REIMPORT;
                ui.SetText(keyText);
                ui.SetFontSize(UIScaler.GetMediumFont());
                ui.SetButton(delegate { Import("MoM", !MoM_import_available); });
                ui.SetBGColor(new Color(0, 0.03f, 0f));
                new UIElementBorder(ui);
            }
            else // Import unavailable
            {
                // only install button for Android
                if (Application.platform == RuntimePlatform.Android)
                {
                    ui = new UIElement();
                    ui.SetLocation((UIScaler.GetWidthUnits() - 24) / 2, offset + 3.2f, 24, 1.3f);
                    ui.SetText(CONTENT_INSTALL_VIA_GOOGLEPLAY, Color.red);
                    ui.SetButton(delegate { GotoWebBrowser(MOM_APP_URL_ANDROID); });
                    new UIElementBorder(ui, Color.red);
                }
                else
                {
                    // install and locate button for other systems
                    ui = new UIElement();
                    ui.SetLocation((UIScaler.GetWidthUnits() / 2) - 13, offset + 3.2f, 12, 1.3f);
                    ui.SetText(CONTENT_INSTALL_VIA_STEAM, Color.red);
                    ui.SetButton(delegate { GotoWebBrowser(MOM_APP_URL_STEAM); });
                    new UIElementBorder(ui, Color.red);

                    ui = new UIElement();
                    ui.SetLocation((UIScaler.GetWidthUnits() / 2) + 1, offset + 3.2f, 12, 1.3f);
                    ui.SetText(CONTENT_LOCATE, Color.red);
                    ui.SetButton(delegate { Import("MoM", true); });
                    new UIElementBorder(ui, Color.red);
                }
            }


#if IA
            // Draw IA button
            startColor = Color.white;
            if (fcIA.NeedImport())
            {
                startColor = Color.gray;
            }
            // Always disabled
            startColor = Color.gray;
            ui         = new UIElement();
            ui.SetLocation((UIScaler.GetWidthUnits() - 30) / 2, 21, 30, 3);
            ui.SetText(IA_NAME, startColor);
            ui.SetFontSize(UIScaler.GetMediumFont());
            //ui.SetButton(delegate { IA(); });
            ui.SetBGColor(new Color(0, 0.03f, 0f));
            new UIElementBorder(ui, startColor);

            // Draw IA import button
            ui = new UIElement();
            if (fcIA.ImportAvailable())
            {
                ui.SetLocation((UIScaler.GetWidthUnits() - 14) / 2, 24.2f, 14, 2);
                StringKey keyText = fcIA.NeedImport() ? CONTENT_IMPORT : CONTENT_REIMPORT;
                ui.SetText(keyText);
                ui.SetFontSize(UIScaler.GetMediumFont());
                ui.SetButton(delegate { Import("IA"); });
                ui.SetBGColor(new Color(0, 0.03f, 0f));
                new UIElementBorder(ui);
            }
            else // Import unavailable
            {
                ui.SetLocation((UIScaler.GetWidthUnits() - 24) / 2, 24.2f, 24, 1);
                if (Application.platform == RuntimePlatform.Android)
                {
                    ui.SetText(IA_APP_NOT_FOUND_ANDROID, Color.red);
                }
                else
                {
                    ui.SetText(IA_APP_NOT_FOUND, Color.red);
                }
                new UIElementBorder(ui, Color.red);
            }
#endif

            ui = new UIElement();
            ui.SetLocation(1, UIScaler.GetBottom(-3), 8, 2);
            ui.SetText(CommonStringKeys.EXIT, Color.red);
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(Exit);
            ui.SetBGColor(new Color(0, 0.03f, 0f));
            new UIElementBorder(ui, Color.red);

            // will display a button if a new version is available
            VersionManager.GetLatestVersionAsync(CheckForNewValkyrieVersion);
        }
Ejemplo n.º 27
0
        public void Draw()
        {
            // Clean up
            Destroyer.Dialog();
            foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.HEROSELECT))
            {
                Object.Destroy(go);
            }

            Game game = Game.Get();

            // Add a title to the page
            UIElement ui = new UIElement(Game.HEROSELECT);

            ui.SetLocation(8, 1, UIScaler.GetWidthUnits() - 16, 3);
            ui.SetText(new StringKey("val", "SELECT_CLASS"));
            ui.SetFont(Game.Get().gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetLargeFont());

            // Get all heros
            int heroCount = 0;

            // Count number of selected heroes
            foreach (Quest.Hero h in game.quest.heroes)
            {
                if (h.heroData != null)
                {
                    heroCount++;
                }
            }

            float xOffset = UIScaler.GetHCenter(-18);

            if (heroCount < 4)
            {
                xOffset += 4.5f;
            }
            if (heroCount < 3)
            {
                xOffset += 4.5f;
            }

            for (int i = 0; i < heroCount; i++)
            {
                DrawHero(xOffset, i);
                xOffset += 9f;
            }

            // Add a finished button to start the quest
            ui = new UIElement(Game.HEROSELECT);
            ui.SetLocation(UIScaler.GetRight(-8.5f), UIScaler.GetBottom(-2.5f), 8, 2);
            ui.SetText(CommonStringKeys.FINISHED, Color.green);
            ui.SetFont(Game.Get().gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(Finished);
            new UIElementBorder(ui, Color.green);

            ui = new UIElement(Game.HEROSELECT);
            ui.SetLocation(0.5f, UIScaler.GetBottom(-2.5f), 8, 2);
            ui.SetText(CommonStringKeys.BACK, Color.red);
            ui.SetFont(Game.Get().gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(Destroyer.QuestSelect);
            new UIElementBorder(ui, Color.red);
        }
Ejemplo n.º 28
0
        public QuestSelectionScreen(Dictionary <string, QuestData.Quest> ql)
        {
            questList = ql;
            Game game = Game.Get();

            // If a dialog window is open we force it closed (this shouldn't happen)
            foreach (GameObject go in GameObject.FindGameObjectsWithTag("dialog"))
            {
                Object.Destroy(go);
            }

            // Clean up downloader if present
            foreach (GameObject go in GameObject.FindGameObjectsWithTag("questui"))
            {
                Object.Destroy(go);
            }

            // Heading
            DialogBox db = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 3), "Select " + game.gameType.QuestName());

            db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont();
            db.SetFont(game.gameType.GetHeaderFont());

            db = new DialogBox(new Vector2(1, 5f), new Vector2(UIScaler.GetWidthUnits() - 2f, 21f), "");
            db.AddBorder();
            db.background.AddComponent <UnityEngine.UI.Mask>();
            UnityEngine.UI.ScrollRect scrollRect = db.background.AddComponent <UnityEngine.UI.ScrollRect>();

            GameObject    scrollArea      = new GameObject("scroll");
            RectTransform scrollInnerRect = scrollArea.AddComponent <RectTransform>();

            scrollArea.transform.parent = db.background.transform;
            scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 1);
            scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, (UIScaler.GetWidthUnits() - 3f) * UIScaler.GetPixelsPerUnit());

            scrollRect.content    = scrollInnerRect;
            scrollRect.horizontal = false;

            TextButton tb;
            // Start here
            float offset = 5;

            // Loop through all available quests
            foreach (KeyValuePair <string, QuestData.Quest> q in questList)
            {
                if (q.Value.GetMissingPacks(game.cd.GetEnabledPackIDs()).Count == 0)
                {
                    string key = q.Key;
                    // Size is 1.2 to be clear of characters with tails
                    tb = new TextButton(new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 5, 1.2f), "  " + q.Value.name, delegate { Selection(key); }, Color.black, (int)offset);
                    tb.button.GetComponent <UnityEngine.UI.Text>().material   = (Material)Resources.Load("Fonts/FontMaterial");
                    tb.button.GetComponent <UnityEngine.UI.Text>().fontSize   = UIScaler.GetSmallFont();
                    tb.button.GetComponent <UnityEngine.UI.Text>().alignment  = TextAnchor.MiddleLeft;
                    tb.background.GetComponent <UnityEngine.UI.Image>().color = Color.white;
                    tb.background.transform.parent = scrollArea.transform;
                    offset += 2;
                }
            }

            // Loop through all unavailable quests
            foreach (KeyValuePair <string, QuestData.Quest> q in questList)
            {
                if (q.Value.GetMissingPacks(game.cd.GetEnabledPackIDs()).Count > 0)
                {
                    // Size is 1.2 to be clear of characters with tails
                    db = new DialogBox(new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 5, 1.2f), "  " + q.Value.name, Color.black);
                    db.textObj.GetComponent <UnityEngine.UI.Text>().material  = (Material)Resources.Load("Fonts/FontMaterial");
                    db.textObj.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft;
                    db.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.4f, 0.4f, 0.4f);
                    db.background.transform.parent = scrollArea.transform;
                    offset += 1.2f;
                    foreach (string s in q.Value.GetMissingPacks(game.cd.GetEnabledPackIDs()))
                    {
                        db = new DialogBox(new Vector2(4, offset), new Vector2(UIScaler.GetWidthUnits() - 9, 1.2f), " Requires:  " + game.cd.GetContentName(s), Color.black);
                        db.textObj.GetComponent <UnityEngine.UI.Text>().material  = (Material)Resources.Load("Fonts/FontMaterial");
                        db.textObj.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft;
                        db.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.4f, 0.4f, 0.4f);
                        db.background.transform.parent = scrollArea.transform;
                        offset += 1.2f;
                    }
                }
                offset += 0.8f;
            }

            scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, (offset - 5) * UIScaler.GetPixelsPerUnit());

            tb = new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), "Back", delegate { Cancel(); }, Color.red);
            tb.SetFont(game.gameType.GetHeaderFont());

            tb = new TextButton(new Vector2(UIScaler.GetRight(-9), UIScaler.GetBottom(-3)), new Vector2(8, 2), "Download", delegate { Download(); }, Color.green);
            tb.SetFont(game.gameType.GetHeaderFont());
        }
Ejemplo n.º 29
0
    // Create a pack with list of quests to edit
    public QuestEditSelection()
    {
        Game game = Game.Get();

        // Get list of unpacked quest in user location (editable)
        // TODO: open/save in packages
        questList = QuestLoader.GetUserUnpackedQuests();

        // If a dialog window is open we force it closed (this shouldn't happen)
        foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.DIALOG))
        {
            Object.Destroy(go);
        }

        // Heading
        DialogBox db = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 3),
                                     new StringKey("val", "SELECT", game.gameType.QuestName()));

        db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont();
        db.SetFont(Game.Get().gameType.GetHeaderFont());

        UIElementScrollVertical scrollArea = new UIElementScrollVertical();

        scrollArea.SetLocation(1, 5, UIScaler.GetWidthUnits() - 2f, 21);
        new UIElementBorder(scrollArea);

        // List of quests
        int        offset = 0;
        TextButton tb;

        foreach (KeyValuePair <string, QuestData.Quest> q in questList)
        {
            string key = q.Key;
            LocalizationRead.scenarioDict = q.Value.localizationDict;
            string translation = q.Value.name.Translate();

            UIElement ui = new UIElement(scrollArea.GetScrollTransform());
            ui.SetLocation(1, offset, UIScaler.GetWidthUnits() - 5, 1.2f);
            ui.SetText(new StringKey("val", "INDENT", translation), Color.black);
            ui.SetButton(delegate { Selection(key); });
            ui.SetBGColor(Color.white);
            offset += 2;
        }
        scrollArea.SetScrollSize(offset);

        // Main menu
        tb = new TextButton(
            new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), CommonStringKeys.BACK, delegate { Cancel(); }, Color.red);
        tb.SetFont(Game.Get().gameType.GetHeaderFont());
        // Delete a user quest
        tb = new TextButton(
            new Vector2((UIScaler.GetRight() * 3 / 8) - 4, UIScaler.GetBottom(-3)), new Vector2(8, 2), CommonStringKeys.DELETE, delegate { Delete(); }, Color.red);
        tb.SetFont(Game.Get().gameType.GetHeaderFont());
        // Copy a quest
        tb = new TextButton(
            new Vector2((UIScaler.GetRight() * 5 / 8) - 4, UIScaler.GetBottom(-3)), new Vector2(8, 2), CommonStringKeys.COPY, delegate { Copy(); });
        tb.SetFont(Game.Get().gameType.GetHeaderFont());
        // Create a new quest
        tb = new TextButton(
            new Vector2(UIScaler.GetRight(-9), UIScaler.GetBottom(-3)), new Vector2(8, 2),
            CommonStringKeys.NEW, delegate { NewQuest(); });
        tb.SetFont(Game.Get().gameType.GetHeaderFont());
    }
Ejemplo n.º 30
0
    /// <summary>
    /// Draw download options screen
    /// </summary>
    public void DrawList()
    {
        Destroyer.Dialog();
        localManifest = IniRead.ReadFromString("");
        if (File.Exists(saveLocation() + "/manifest.ini"))
        {
            localManifest = IniRead.ReadFromIni(saveLocation() + "/manifest.ini");
        }

        // Heading
        UIElement ui = new UIElement();

        ui.SetLocation(2, 1, UIScaler.GetWidthUnits() - 4, 3);
        ui.SetText(new StringKey("val", "QUEST_NAME_DOWNLOAD", game.gameType.QuestName()));
        ui.SetFont(game.gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetLargeFont());

        UIElementScrollVertical scrollArea = new UIElementScrollVertical();

        scrollArea.SetLocation(1, 5, UIScaler.GetWidthUnits() - 2f, 21f);
        new UIElementBorder(scrollArea);

        // Start here
        float offset = 0;

        // Loop through all available quests
        foreach (RemoteQuest rq in remoteQuests)
        {
            string file      = rq.name + ".valkyrie";
            string questName = rq.GetData("name." + game.currentLang);
            if (questName.Length == 0)
            {
                questName = rq.GetData("name." + rq.GetData("defaultlanguage"));
            }
            if (questName.Length == 0)
            {
                questName = rq.name;
            }

            int remoteFormat = 0;
            int.TryParse(rq.GetData("format"), out remoteFormat);
            bool formatOK = (remoteFormat >= QuestData.Quest.minumumFormat) && (remoteFormat <= QuestData.Quest.currentFormat);

            if (!formatOK)
            {
                continue;
            }

            bool exists = File.Exists(saveLocation() + "/" + file);
            bool update = true;
            if (exists)
            {
                string localHash  = localManifest.Get(rq.name, "version");
                string remoteHash = rq.GetData("version");

                update = !localHash.Equals(remoteHash);
            }

            Color bg = Color.white;
            if (exists)
            {
                bg = new Color(0.7f, 0.7f, 1f);
                if (!update)
                {
                    bg = new Color(0.1f, 0.1f, 0.1f);
                }
            }

            // Frame
            ui = new UIElement(scrollArea.GetScrollTransform());
            ui.SetLocation(0.95f, offset, UIScaler.GetWidthUnits() - 4.9f, 3.1f);
            ui.SetBGColor(bg);
            if (update)
            {
                ui.SetButton(delegate { Selection(rq); });
            }
            offset += 0.05f;

            // Draw Image
            ui = new UIElement(scrollArea.GetScrollTransform());
            ui.SetLocation(1, offset, 3, 3);
            ui.SetBGColor(bg);
            if (update)
            {
                ui.SetButton(delegate { Selection(rq); });
            }

            if (rq.image != null)
            {
                ui.SetImage(rq.image);
            }

            ui = new UIElement(scrollArea.GetScrollTransform());
            ui.SetBGColor(Color.clear);
            ui.SetLocation(4, offset, UIScaler.GetWidthUnits() - 8, 3f);
            ui.SetTextPadding(1.2f);
            if (update && exists)
            {
                ui.SetText(new StringKey("val", "QUEST_NAME_UPDATE", questName), Color.black);
            }
            else
            {
                ui.SetText(questName, Color.black);
            }
            if (update)
            {
                ui.SetButton(delegate { Selection(rq); });
            }
            ui.SetTextAlignment(TextAnchor.MiddleLeft);
            ui.SetFontSize(Mathf.RoundToInt(UIScaler.GetSmallFont() * 1.3f));

            // Duration
            int lengthMax = 0;
            int.TryParse(rq.GetData("lengthmax"), out lengthMax);
            if (lengthMax > 0)
            {
                int lengthMin = 0;
                int.TryParse(rq.GetData("lengthmin"), out lengthMin);

                ui = new UIElement(scrollArea.GetScrollTransform());
                ui.SetLocation(UIScaler.GetRight(-11), offset, 2, 1);
                ui.SetText(lengthMin.ToString(), Color.black);
                ui.SetBGColor(Color.clear);

                ui = new UIElement(scrollArea.GetScrollTransform());
                ui.SetLocation(UIScaler.GetRight(-9), offset, 1, 1);
                ui.SetText("-", Color.black);
                ui.SetBGColor(Color.clear);

                ui = new UIElement(scrollArea.GetScrollTransform());
                ui.SetLocation(UIScaler.GetRight(-8), offset, 2, 1);
                ui.SetText(lengthMax.ToString(), Color.black);
                ui.SetBGColor(Color.clear);
            }

            // Difficulty
            float difficulty = 0;
            float.TryParse(rq.GetData("difficulty"), out difficulty);
            if (difficulty != 0)
            {
                string symbol = "π"; // will
                if (game.gameType is MoMGameType)
                {
                    symbol = new StringKey("val", "ICON_SUCCESS_RESULT").Translate();
                }
                ui = new UIElement(scrollArea.GetScrollTransform());
                ui.SetLocation(UIScaler.GetRight(-13), offset + 1, 9, 2);
                ui.SetText(symbol + symbol + symbol + symbol + symbol, Color.black);
                ui.SetBGColor(Color.clear);
                ui.SetFontSize(UIScaler.GetMediumFont());

                ui = new UIElement(scrollArea.GetScrollTransform());
                ui.SetLocation(UIScaler.GetRight(-11.95f) + (difficulty * 6.9f), offset + 1, (1 - difficulty) * 6.9f, 2);
                Color filter = bg;
                filter.a = 0.7f;
                ui.SetBGColor(filter);
            }

            // Size is 1.2 to be clear of characters with tails
            if (exists)
            {
                ui = new UIElement(scrollArea.GetScrollTransform());
                ui.SetLocation(((UIScaler.GetWidthUnits() - 3) / 2) - 4, offset + 2.5f, 8, 1.2f);
                ui.SetBGColor(new Color(0.7f, 0, 0));
                ui.SetText(CommonStringKeys.DELETE, Color.black);
                ui.SetButton(delegate { Delete(file); });
                offset += 0.5f;
            }
            offset += 4;
        }

        foreach (KeyValuePair <string, Dictionary <string, string> > kv in localManifest.data)
        {
            // Only looking for files missing from remote
            bool onRemote = false;
            foreach (RemoteQuest rq in remoteQuests)
            {
                if (rq.name.Equals(kv.Key))
                {
                    onRemote = true;
                }
            }
            if (onRemote)
            {
                continue;
            }

            string type = localManifest.Get(kv.Key, "type");

            // Only looking for packages of this game type
            if (!game.gameType.TypeName().Equals(type))
            {
                continue;
            }

            string file = kv.Key + ".valkyrie";
            // Size is 1.2 to be clear of characters with tails
            if (File.Exists(saveLocation() + "/" + file))
            {
                ui = new UIElement(scrollArea.GetScrollTransform());
                ui.SetLocation(1, offset, UIScaler.GetWidthUnits() - 8, 1.2f);
                ui.SetTextPadding(1.2f);
                ui.SetText(file, Color.black);
                ui.SetBGColor(new Color(0.1f, 0.1f, 0.1f));
                ui.SetTextAlignment(TextAnchor.MiddleLeft);

                ui = new UIElement(scrollArea.GetScrollTransform());
                ui.SetLocation(UIScaler.GetWidthUnits() - 12, offset, 8, 1.2f);
                ui.SetText(CommonStringKeys.DELETE, Color.black);
                ui.SetTextAlignment(TextAnchor.MiddleLeft);
                ui.SetButton(delegate { Delete(file); });
                ui.SetBGColor(new Color(0.7f, 0, 0));
                offset += 2;
            }
        }

        scrollArea.SetScrollSize(offset);

        ui = new UIElement();
        ui.SetLocation(1, UIScaler.GetBottom(-3), 8, 2);
        ui.SetText(CommonStringKeys.BACK, Color.red);
        ui.SetButton(delegate { Cancel(); });
        ui.SetFont(game.gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetMediumFont());
        new UIElementBorder(ui, Color.red);
    }