Exemple #1
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);
    }
Exemple #2
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);
    }
Exemple #3
0
    // Draw up button if > 5 monsters, disabled if at top
    public void DrawUp()
    {
        Game game = Game.Get();

        // Check if scroll required
        if (game.quest.monsters.Count < 6 && offset == 0)
        {
            return;
        }
        // If at top
        if (offset == 0)
        {
            TextButton up = new TextButton(new Vector2(UIScaler.GetRight(-4.25f), 1), new Vector2(4, 2), "/\\", delegate { noAction(); }, Color.gray);
            up.ApplyTag("monsters");
        }
        else
        { // Scroll up active
            TextButton up = new TextButton(new Vector2(UIScaler.GetRight(-4.25f), 1), new Vector2(4, 2), "/\\", delegate { Move(-1); });
            up.ApplyTag("monsters");
        }
    }
Exemple #4
0
    // Draw down button if > 5 monsters, disabled if at bottom
    public void DrawDown()
    {
        Game game = Game.Get();

        // Check if scroll required
        if (game.quest.monsters.Count < 6)
        {
            return;
        }
        // If at buttom
        if (game.quest.monsters.Count - offset < 6)
        {
            TextButton down = new TextButton(new Vector2(UIScaler.GetRight(-4.25f), 27), new Vector2(4, 2), "\\/", delegate { noAction(); }, Color.gray);
            down.ApplyTag("monsters");
        }
        else
        { // Scroll down active
            TextButton down = new TextButton(new Vector2(UIScaler.GetRight(-4.25f), 27), new Vector2(4, 2), "\\/", delegate { Move(); });
            down.ApplyTag("monsters");
        }
    }
Exemple #5
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");
    }
Exemple #6
0
    // Draw items
    public virtual void CreateWindow()
    {
        Game game = Game.Get();
        // Count the monster number
        int index = 0;

        for (int i = 0; i < game.quest.monsters.Count; i++)
        {
            if (game.quest.monsters[i] == monster)
            {
                index = i;
            }
        }

        // Work out where on the screen to display
        float offset = (index + 0.1f - game.monsterCanvas.offset) * (MonsterCanvas.monsterSize + 0.5f);

        if (GameObject.FindGameObjectWithTag("activation") != null)
        {
            offset += 2.8f;
        }

        new TextButton(new Vector2(UIScaler.GetRight(-10.5f - MonsterCanvas.monsterSize), offset), new Vector2(10, 2), INFORMATION, delegate { Info(); });
        offset += 2.5f;
        if (GameObject.FindGameObjectWithTag("activation") == null)
        {
            new TextButton(new Vector2(UIScaler.GetRight(-10.5f - MonsterCanvas.monsterSize), offset), new Vector2(10, 2), FORCE_ACTIVATE, delegate { Activate(); });
            offset += 2.5f;
            new TextButton(new Vector2(UIScaler.GetRight(-10.5f - MonsterCanvas.monsterSize), offset), new Vector2(10, 2), DEFEATED, delegate { Defeated(); });
            offset += 2.5f;
            if (monster.unique)
            {
                // If there is a unique option the offset needs to be increased
                new TextButton(new Vector2(UIScaler.GetRight(-10.5f - MonsterCanvas.monsterSize), offset), new Vector2(10, 3), UNIQUE_DEFEATED, delegate { UniqueDefeated(); });
                offset += 3.5f;
            }
        }
        // FIXME: This doesn't fit if there is a unique monster in the last space
        new TextButton(new Vector2(UIScaler.GetRight(-10.5f - MonsterCanvas.monsterSize), offset), new Vector2(10, 2), CommonStringKeys.CANCEL, delegate { OnCancel(); });
    }
Exemple #7
0
    // Render hero buttons, starting at scroll offset
    public void RenderPage(int heroId, int offset)
    {
        foreach (GameObject go in GameObject.FindGameObjectsWithTag("dialog"))
        {
            Object.Destroy(go);
        }

        Game game = Game.Get();

        // Starting array position
        float x = 8;
        float y = 5 - (5f * offset);

        // If we haven't scrolled down
        if (y > 4)
        {
            // Create an 'empty' button to clear selection
            HeroSelectButton(new Vector2(x, y), null, heroId);
        }

        // Get all available heros
        List <string> heroList = new List <string>(game.cd.heros.Keys);

        heroList.Sort();

        bool prevPage = false;
        bool nextPage = false;

        foreach (string hero in heroList)
        {
            // Shift to the right
            x += 5f;
            // If too far right move down
            if (x > UIScaler.GetRight(-13))
            {
                x  = 8;
                y += 5f;
            }

            // If too far down set scroll down
            if (y >= 24)
            {
                nextPage = true;
            }
            // If too high set scroll up
            else if (y < 4)
            {
                prevPage = true;
            }
            else
            { // hero in scroll range
                bool disabled = false;
                foreach (Quest.Hero hIt in game.quest.heroes)
                {
                    if ((hIt.heroData == game.cd.heros[hero]) && (hIt.id != heroId))
                    {
                        // Hero already picked
                        disabled = true;
                    }
                }
                HeroSelectButton(new Vector2(x, y), game.cd.heros[hero], heroId, disabled);
            }
        }

        // Are we scrolling?
        if (prevPage || nextPage)
        {
            PrevButton(!prevPage, heroId, offset);
            NextButton(!nextPage, heroId, offset);
        }
    }
Exemple #8
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);
        }
Exemple #9
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("dialog"))
        {
            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.Get().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.Left, 0, (UIScaler.GetWidthUnits() - 3f) * UIScaler.GetPixelsPerUnit());
        scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 1);

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

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

        foreach (KeyValuePair <string, QuestData.Quest> q in questList)
        {
            string key = q.Key;
            tb = new TextButton(new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 5, 1.2f), "  " + q.Value.name, delegate { Selection(key); }, Color.black, offset);
            tb.button.GetComponent <UnityEngine.UI.Text>().fontSize   = UIScaler.GetSmallFont();
            tb.button.GetComponent <UnityEngine.UI.Text>().material   = (Material)Resources.Load("Fonts/FontMaterial");
            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;
        }
        scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, (offset - 5) * UIScaler.GetPixelsPerUnit());

        // Main menu
        tb = new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), "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), "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), "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), "New", delegate { NewQuest(); });
        tb.SetFont(Game.Get().gameType.GetHeaderFont());
    }
Exemple #10
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() + Path.DirectorySeparatorChar + file);
            bool update = true;
            if (exists)
            {
                string localHash  = localManifest.Get(rq.name, "version");
                string remoteHash = rq.GetData("version");

                update = !localHash.Equals(remoteHash);
            }

            bool has_stats_bar = false;


            Color bg         = Color.white;
            Color text_color = Color.black;
            if (exists)
            {
                if (update)
                {
                    // light pink
                    bg         = new Color(0.7f, 0.7f, 1f);
                    text_color = Color.black;
                }
                else
                {
                    // dark grey
                    bg         = new Color(0.1f, 0.1f, 0.1f);
                    text_color = Color.grey;
                }
            }

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

            // Draw Image
            ui = new UIElement(scrollArea.GetScrollTransform());
            ui.SetLocation(1, offset, 3.5f, 3.5f);
            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(5, offset, UIScaler.GetWidthUnits() - 8, 2.5f);
            ui.SetTextPadding(1.2f);
            if (update && exists)
            {
                ui.SetText(new StringKey("val", "QUEST_NAME_UPDATE", questName), text_color);
            }
            else
            {
                ui.SetText(questName, text_color);
            }
            if (update)
            {
                ui.SetButton(delegate { Selection(rq); });
            }
            ui.SetTextAlignment(TextAnchor.MiddleLeft);
            ui.SetFontSize(Mathf.RoundToInt(UIScaler.GetSmallFont() * 1.4f));

            // 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(7f, offset + 2.3f, 4, 1);
                ui.SetText(new StringKey("val", "DURATION"), text_color);
                ui.SetTextAlignment(TextAnchor.MiddleLeft);
                ui.SetBGColor(Color.clear);
                if (update)
                {
                    ui.SetButton(delegate { Selection(rq); });
                }

                ui = new UIElement(scrollArea.GetScrollTransform());
                ui.SetLocation(11f, offset + 2.3f, 5, 1);
                ui.SetText(lengthMin + "  -  " + lengthMax, text_color);
                ui.SetTextAlignment(TextAnchor.MiddleLeft);
                ui.SetBGColor(Color.clear);
                if (update)
                {
                    ui.SetButton(delegate { Selection(rq); });
                }
            }

            // Difficulty
            float difficulty = 0f;
            float.TryParse(rq.GetData("difficulty"), out difficulty);
            if (difficulty != 0)
            {
                ui = new UIElement(scrollArea.GetScrollTransform());
                ui.SetLocation(UIScaler.GetHCenter() - 5.5f, offset + 2.3f, 6, 1);
                ui.SetText(new StringKey("val", "DIFFICULTY"), text_color);
                if (update)
                {
                    ui.SetButton(delegate { Selection(rq); });
                }
                ui.SetTextAlignment(TextAnchor.MiddleRight);
                ui.SetBGColor(Color.clear);

                string symbol = "π"; // will
                if (game.gameType is MoMGameType)
                {
                    symbol = new StringKey("val", "ICON_SUCCESS_RESULT").Translate();
                }

                ui = new UIElement(scrollArea.GetScrollTransform());
                ui.SetLocation(UIScaler.GetHCenter(), offset + 1.8f, 9, 2);
                ui.SetText(symbol + symbol + symbol + symbol + symbol, text_color);
                ui.SetBGColor(Color.clear);
                ui.SetFontSize(UIScaler.GetMediumFont());
                if (update)
                {
                    ui.SetButton(delegate { Selection(rq); });
                }

                ui = new UIElement(scrollArea.GetScrollTransform());
                ui.SetLocation(UIScaler.GetHCenter() + 1.05f + (difficulty * 6.9f), offset + 1.8f, (1 - difficulty) * 6.9f, 1.6f);
                Color filter = bg;
                filter.a = 0.7f;
                ui.SetBGColor(filter);
                if (update)
                {
                    ui.SetButton(delegate { Selection(rq); });
                }
            }

            // Statistics
            string filename = file.ToLower();
            if (game.stats != null && game.stats.scenarios_stats != null && game.stats.scenarios_stats.ContainsKey(filename))
            {
                ScenarioStats q_stats   = game.stats.scenarios_stats[filename];
                int           win_ratio = (int)(q_stats.scenario_avg_win_ratio * 100);

                StringKey STATS_AVERAGE_WIN_RATIO    = new StringKey("val", "STATS_AVERAGE_WIN_RATIO", win_ratio);
                StringKey STATS_NO_AVERAGE_WIN_RATIO = new StringKey("val", "STATS_NO_AVERAGE_WIN_RATIO", win_ratio);
                StringKey STATS_NB_USER_REVIEWS      = new StringKey("val", "STATS_NB_USER_REVIEWS", q_stats.scenario_play_count);
                StringKey STATS_AVERAGE_DURATION     = new StringKey("val", "STATS_AVERAGE_DURATION", (int)(q_stats.scenario_avg_duration));
                StringKey STATS_NO_AVERAGE_DURATION  = new StringKey("val", "STATS_NO_AVERAGE_DURATION");

                //  rating
                string symbol = "★";
                if (game.gameType is MoMGameType)
                {
                    symbol = new StringKey("val", "ICON_TENTACLE").Translate();
                }
                float rating           = q_stats.scenario_avg_rating / 10;
                float score_text_width = 0;

                ui = new UIElement(scrollArea.GetScrollTransform());

                ui.SetText(symbol + symbol + symbol + symbol + symbol, text_color);
                score_text_width = ui.GetStringWidth(symbol + symbol + symbol + symbol + symbol, (int)System.Math.Round(UIScaler.GetMediumFont() * 1.4f)) + 1;
                ui.SetLocation(UIScaler.GetRight(-12f), offset + 0.6f, score_text_width, 2);
                ui.SetBGColor(Color.clear);
                ui.SetFontSize((int)System.Math.Round(UIScaler.GetMediumFont() * 1.4f));
                ui.SetTextAlignment(TextAnchor.MiddleLeft);
                if (update)
                {
                    ui.SetButton(delegate { Selection(rq); });
                }

                ui = new UIElement(scrollArea.GetScrollTransform());
                ui.SetLocation(UIScaler.GetRight(-12) + (rating * (score_text_width - 1)), offset + 0.6f, (1 - rating) * score_text_width, 2);
                Color filter = bg;
                filter.a = 0.7f;
                ui.SetBGColor(filter);
                if (update)
                {
                    ui.SetButton(delegate { Selection(rq); });
                }

                //  Number of user reviews
                float user_review_text_width = 0;
                ui = new UIElement(scrollArea.GetScrollTransform());
                user_review_text_width = ui.GetStringWidth(STATS_NB_USER_REVIEWS, UIScaler.GetSmallFont()) + 1;
                ui.SetText(STATS_NB_USER_REVIEWS, text_color);
                ui.SetLocation(UIScaler.GetRight(-12) + (score_text_width / 2) - (user_review_text_width / 2), offset + 2.3f, user_review_text_width, 1);
                ui.SetTextAlignment(TextAnchor.MiddleLeft);
                ui.SetBGColor(Color.clear);
                ui.SetFontSize(UIScaler.GetSmallFont());
                if (update)
                {
                    ui.SetButton(delegate { Selection(rq); });
                }

                if (q_stats.scenario_avg_duration > 0 || win_ratio >= 0)
                {
                    has_stats_bar = true;

                    // Additional information in frame
                    ui = new UIElement(scrollArea.GetScrollTransform());
                    ui.SetLocation(3.5f + 1f, offset + 3.6f, UIScaler.GetWidthUnits() - 4.9f - 3.5f - 0.05f, 1.2f);
                    if (exists)
                    {
                        ui.SetBGColor(bg);
                    }
                    else
                    {
                        ui.SetBGColor(new Color(0.8f, 0.8f, 0.8f));
                    }
                    if (update)
                    {
                        ui.SetButton(delegate { Selection(rq); });
                    }

                    //  average duration
                    ui = new UIElement(scrollArea.GetScrollTransform());
                    ui.SetLocation(6f, offset + 3.8f, 14, 1);
                    if (q_stats.scenario_avg_duration > 0)
                    {
                        ui.SetText(STATS_AVERAGE_DURATION, text_color);
                    }
                    else
                    {
                        ui.SetText(STATS_NO_AVERAGE_DURATION, text_color);
                    }
                    ui.SetTextAlignment(TextAnchor.MiddleLeft);
                    ui.SetBGColor(Color.clear);
                    if (update)
                    {
                        ui.SetButton(delegate { Selection(rq); });
                    }

                    //  average win ratio
                    ui = new UIElement(scrollArea.GetScrollTransform());
                    ui.SetLocation(UIScaler.GetHCenter() - 5.5f, offset + 3.8f, 15, 1);
                    if (win_ratio >= 0)
                    {
                        ui.SetText(STATS_AVERAGE_WIN_RATIO, text_color);
                    }
                    else
                    {
                        ui.SetText(STATS_NO_AVERAGE_WIN_RATIO, text_color);
                    }
                    ui.SetBGColor(Color.clear);
                    ui.SetTextAlignment(TextAnchor.MiddleCenter);
                    if (update)
                    {
                        ui.SetButton(delegate { Selection(rq); });
                    }
                }
            }

            // Size is 1.2 to be clear of characters with tails
            if (exists)
            {
                float string_width = 0;

                if (update)
                {
                    ui = new UIElement(scrollArea.GetScrollTransform());
                    ui.SetText(CommonStringKeys.UPDATE, Color.black);
                    string_width = ui.GetStringWidth(CommonStringKeys.UPDATE, UIScaler.GetSmallFont()) + 1.3f;
                    ui.SetButton(delegate { Delete(file); Selection(rq); });
                    ui.SetLocation(0.95f, offset + 3.6f, string_width, 1.2f);
                    ui.SetBGColor(new Color(0, 0.5f, 0.68f));           // 0080AF
                    new UIElementBorder(ui, new Color(0, 0.3f, 0.43f)); // 00516f
                }

                ui = new UIElement(scrollArea.GetScrollTransform());
                ui.SetText(CommonStringKeys.DELETE, Color.black);
                string_width = ui.GetStringWidth(CommonStringKeys.DELETE, UIScaler.GetSmallFont()) + 1.3f;
                ui.SetButton(delegate { Delete(file); });
                ui.SetLocation(0.95f + UIScaler.GetWidthUnits() - 4.9f - string_width, offset + 3.6f, string_width, 1.2f);
                ui.SetBGColor(new Color(0.7f, 0, 0));
                new UIElementBorder(ui, new Color(0.45f, 0, 0));
            }

            if (has_stats_bar || exists)
            {
                offset += 1.2f;
            }

            offset += 4.6f;
        }

        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() + Path.DirectorySeparatorChar + 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);
    }
        public QuestDetailsScreen(QuestData.Quest q)
        {
            Game game = Game.Get();

            LocalizationRead.scenarioDict = q.localizationDict;
            // 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, 0.5f),
                new Vector2(UIScaler.GetWidthUnits() - 4, 3),
                q.name);

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

            // Draw Image
            if (q.image.Length > 0)
            {
                Texture2D tex    = ContentData.FileToTexture(Path.Combine(q.path, q.image));
                Sprite    sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.zero, 1);

                db = new DialogBox(new Vector2(UIScaler.GetHCenter(-20), 4),
                                   new Vector2(8, 8),
                                   StringKey.NULL,
                                   Color.white,
                                   Color.white);
                db.background.GetComponent <UnityEngine.UI.Image>().sprite = sprite;
                db.AddBorder();
            }

            // Draw Description
            db = new DialogBox(Vector2.zero, new Vector2(30, 30), q.description);
            float height = (db.textObj.GetComponent <UnityEngine.UI.Text>().preferredHeight / UIScaler.GetPixelsPerUnit()) + 1;

            db.Destroy();
            if (height > 25)
            {
                height = 25;
            }

            db = new DialogBox(new Vector2(UIScaler.GetHCenter(-7), 15 - (height / 2)), new Vector2(30, height), q.description);
            db.AddBorder();

            // Draw authors
            db     = new DialogBox(Vector2.zero, new Vector2(14, 30), q.authors);
            height = (db.textObj.GetComponent <UnityEngine.UI.Text>().preferredHeight / UIScaler.GetPixelsPerUnit()) + 1;
            db.Destroy();
            if (height > 25)
            {
                height = 25;
            }

            db = new DialogBox(new Vector2(UIScaler.GetHCenter(-23), 18.5f - (height / 2)), new Vector2(14, height), q.authors);
            db.AddBorder();

            // Difficulty
            if (q.difficulty != 0)
            {
                db = new DialogBox(new Vector2(UIScaler.GetHCenter(-13), 27), new Vector2(11, 1), new StringKey("val", "DIFFICULTY"));
                string symbol = "*";
                if (game.gameType is MoMGameType)
                {
                    symbol = new StringKey("val", "ICON_SUCCESS_RESULT").Translate();
                }
                db = new DialogBox(new Vector2(UIScaler.GetHCenter(-13), 28), new Vector2(11, 2), new StringKey(null, symbol + symbol + symbol + symbol + symbol, false));
                db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();
                db = new DialogBox(new Vector2(UIScaler.GetHCenter(-10.95f) + (q.difficulty * 6.9f), 28), new Vector2((1 - q.difficulty) * 6.9f, 2), StringKey.NULL, Color.clear, new Color(0, 0, 0, 0.7f));
            }

            // Duration
            if (q.lengthMax != 0)
            {
                db = new DialogBox(new Vector2(UIScaler.GetHCenter(2), 27), new Vector2(11, 1), new StringKey("val", "DURATION"));
                db = new DialogBox(new Vector2(UIScaler.GetHCenter(2), 28f), new Vector2(4, 2), q.lengthMin);
                db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();
                db = new DialogBox(new Vector2(UIScaler.GetHCenter(6.5f), 28f), new Vector2(2, 2), new StringKey(null, "-", false));
                db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();
                db = new DialogBox(new Vector2(UIScaler.GetHCenter(9), 28f), new Vector2(4, 2), q.lengthMax);
                db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();
            }

            TextButton tb = new TextButton(
                new Vector2(0.5f, UIScaler.GetBottom(-2.5f)), new Vector2(8, 2),
                CommonStringKeys.BACK, delegate { Cancel(); }, Color.red);

            tb.SetFont(game.gameType.GetHeaderFont());

            tb = new TextButton(
                new Vector2(UIScaler.GetRight(-8.5f), UIScaler.GetBottom(-2.5f)), new Vector2(8, 2),
                new StringKey("val", "START"), delegate { Start(q); }, Color.green);
            tb.SetFont(game.gameType.GetHeaderFont());
        }
Exemple #12
0
    public void Update()
    {
        // do not display the button bar when we reach the end of the game screen
        if (Game.Get().quest.questHasEnded)
        {
            return;
        }

        // First tile has not been displayed, button bar is not required yet
        if (!Game.Get().quest.firstTileDisplayed)
        {
            return;
        }

        // do not display the button bar when we are in the editor
        if (Game.Get().editMode)
        {
            return;
        }

        // 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, 0, 0.9f);
        }

        float     string_width = 0f, offset = 0.5f;
        StringKey text;

        // Inventory button
        UIElement ui = new UIElement(Game.UIPHASE);

        text = new StringKey("val", "ITEMS_SMALL");
        ui.SetText(text);
        string_width = ui.GetStringWidth(text, UIScaler.GetMediumFont(), Game.Get().gameType.GetHeaderFont()) + 0.5f;
        ui.SetLocation(offset, UIScaler.GetBottom(-2.5f), string_width, 2);
        ui.SetFont(Game.Get().gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetButton(Items);
        ui.SetBGColor(bgColor);
        new UIElementBorder(ui);
        offset += string_width;

        // Action button
        ui   = new UIElement(Game.UIPHASE);
        text = CommonStringKeys.SET;
        ui.SetText(text);
        string_width = ui.GetStringWidth(text, UIScaler.GetMediumFont(), Game.Get().gameType.GetHeaderFont()) + 0.5f;
        ui.SetLocation(offset, UIScaler.GetBottom(-2.5f), string_width, 2);
        ui.SetFont(Game.Get().gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetButton(Set);
        ui.SetBGColor(bgColor);
        new UIElementBorder(ui);
        offset += string_width;

        // Log button (text from previous event)
        ui   = new UIElement(Game.UIPHASE);
        text = CommonStringKeys.LOG;
        ui.SetText(text);
        string_width = ui.GetStringWidth(text, UIScaler.GetMediumFont(), Game.Get().gameType.GetHeaderFont()) + 0.5f;
        ui.SetLocation(offset, UIScaler.GetBottom(-2.5f), string_width, 2);
        ui.SetFont(Game.Get().gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetButton(Log);
        ui.SetBGColor(bgColor);
        new UIElementBorder(ui);
        offset += string_width;

        // Text description for current phase
        ui = new UIElement(Game.UIPHASE);
        Color color;

        if (phase == PHASE_INVESTIGATOR)
        {
            color = Color.white;
        }
        else
        {
            color = Color.red;
        }

        ui.SetText(phase, color);
        string_width = ui.GetStringWidth(phase, UIScaler.GetMediumFont(), Game.Get().gameType.GetHeaderFont()) + 0.5f;
        ui.SetLocation(offset + ((UIScaler.GetRight(-4f) - offset - string_width) * 0.5f), UIScaler.GetBottom(-1.8f), string_width, 1.8f);
        ui.SetBGColor(bgColor);
        ui.SetFont(Game.Get().gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetFontStyle(FontStyle.Italic);

        // Next phase button
        // Tweak border size so that arrow is centered, should be changed if using another character or picture
        ui = new UIElement(Game.UIPHASE);
        ui.SetLocation(UIScaler.GetRight(-4f), UIScaler.GetBottom(-2.5f), 3f, 2.25f);
        new UIElementBorder(ui);
        // make button slightly smaller so it does not overlap border
        ui = new UIElement(Game.UIPHASE);
        ui.SetLocation(UIScaler.GetRight(-3.95f), UIScaler.GetBottom(-2.45f), 2.9f, 1.9f);
        ui.SetText(CommonStringKeys.TAB);
        ui.SetFont(Game.Get().gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetLargeFont());
        ui.SetButton(Next);
        ui.SetBGColor(bgColor);
    }
Exemple #13
0
        // Draw monster if in scroll range (offset is scroll position)
        public void Draw(int offset)
        {
            float top_position_y = 4.3f; //3.75
            float offset_y       = 4.4f; // 4.5

            // Check if in scroll range
            if (index < offset)
            {
                return;
            }
            if (index > offset + 4)
            {
                return;
            }

            GameObject mImg = new GameObject("monsterImg" + m.monsterData.name);

            mImg.tag = Game.MONSTERS;
            mImg.transform.SetParent(game.uICanvas.transform);

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

            trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, (top_position_y + ((index - offset) * offset_y)) * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());
            trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Right, 0.25f * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());
            mImg.AddComponent <CanvasRenderer>();

            icon        = mImg.AddComponent <UnityEngine.UI.Image>();
            icon.sprite = iconSprite;
            icon.rectTransform.sizeDelta = new Vector2(monsterSize * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());

            UnityEngine.UI.Button button = mImg.AddComponent <UnityEngine.UI.Button>();
            button.interactable = true;
            button.onClick.AddListener(delegate { MonsterDiag(); });

            iconFrame = null;
            if (game.gameType is D2EGameType)
            {
                icon.rectTransform.sizeDelta = new Vector2(monsterSize * UIScaler.GetPixelsPerUnit() * 0.83f, monsterSize * UIScaler.GetPixelsPerUnit() * 0.83f);
                GameObject mImgFrame = new GameObject("monsterFrame" + m.monsterData.name);
                mImgFrame.tag = Game.MONSTERS;
                mImgFrame.transform.SetParent(game.uICanvas.transform);

                RectTransform transFrame = mImgFrame.AddComponent <RectTransform>();
                transFrame.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, (top_position_y + ((index - offset) * offset_y)) * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());
                transFrame.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Right, 0.25f * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());
                mImgFrame.AddComponent <CanvasRenderer>();

                iconFrame        = mImgFrame.AddComponent <UnityEngine.UI.Image>();
                iconFrame.sprite = frameSprite;
                iconFrame.rectTransform.sizeDelta = new Vector2(monsterSize * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());

                UnityEngine.UI.Button buttonFrame = mImgFrame.AddComponent <UnityEngine.UI.Button>();
                buttonFrame.interactable = true;
                buttonFrame.onClick.AddListener(delegate { MonsterDiag(); });

                if (m.GetHealth() != 0)
                {
                    UIElement ui = new UIElement(Game.MONSTERS);
                    ui.SetLocation(UIScaler.GetRight(-2.25f), 5.75f + ((index - offset) * offset_y), 2, 2);
                    ui.SetText(m.GetHealth().ToString(), Color.red);
                    ui.SetFontSize(UIScaler.GetMediumFont());
                    ui.SetButton(MonsterDiag);
                    new UIElementBorder(ui, Color.red);
                }
            }
            else
            {
                // MoM
                if (game.quest.phase == Quest.MoMPhase.investigator)
                {
                    DrawAwareness(top_position_y + ((index - offset) * offset_y));
                }
                else
                {
                    DrawHorror(top_position_y + ((index - offset) * offset_y));
                }
            }

            iconDupe = null;
            if (duplicateSprite != null)
            {
                GameObject mImgDupe = new GameObject("monsterDupe" + m.monsterData.name);
                mImgDupe.tag = Game.MONSTERS;
                mImgDupe.transform.SetParent(game.uICanvas.transform);

                RectTransform dupeFrame = mImgDupe.AddComponent <RectTransform>();
                dupeFrame.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, ((monsterSize / 2f) + top_position_y + ((index - offset) * offset_y)) * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit() / 2f);
                dupeFrame.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Right, 2.25f * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit() / 2f);
                mImgDupe.AddComponent <CanvasRenderer>();

                iconDupe        = mImgDupe.AddComponent <UnityEngine.UI.Image>();
                iconDupe.sprite = duplicateSprite;
                iconDupe.rectTransform.sizeDelta = new Vector2(monsterSize * UIScaler.GetPixelsPerUnit() / 2f, monsterSize * UIScaler.GetPixelsPerUnit() / 2f);

                UnityEngine.UI.Button buttonDupe = mImgDupe.AddComponent <UnityEngine.UI.Button>();
                buttonDupe.interactable = true;
                buttonDupe.onClick.AddListener(delegate { MonsterDiag(); });
            }

            Update();
        }
Exemple #14
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);
    }
    // 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("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());

        db = new DialogBox(new Vector2(1, 5f), new Vector2(UIScaler.GetWidthUnits() - 2f, 21f), StringKey.NULL);
        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.Left, 0, (UIScaler.GetWidthUnits() - 3f) * UIScaler.GetPixelsPerUnit());
        scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 1);

        GameObject scrollBarObj = new GameObject("scrollbar");

        scrollBarObj.transform.parent = db.background.transform;
        RectTransform scrollBarRect = scrollBarObj.AddComponent <RectTransform>();

        scrollBarRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 21 * UIScaler.GetPixelsPerUnit());
        scrollBarRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, (UIScaler.GetWidthUnits() - 3f) * UIScaler.GetPixelsPerUnit(), 1 * UIScaler.GetPixelsPerUnit());
        UnityEngine.UI.Scrollbar scrollBar = scrollBarObj.AddComponent <UnityEngine.UI.Scrollbar>();
        scrollBar.direction          = UnityEngine.UI.Scrollbar.Direction.BottomToTop;
        scrollRect.verticalScrollbar = scrollBar;

        GameObject scrollBarHandle = new GameObject("scrollbarhandle");

        scrollBarHandle.transform.parent = scrollBarObj.transform;
        //RectTransform scrollBarHandleRect = scrollBarHandle.AddComponent<RectTransform>();
        scrollBarHandle.AddComponent <UnityEngine.UI.Image>();
        scrollBarHandle.GetComponent <UnityEngine.UI.Image>().color = new Color(0.7f, 0.7f, 0.7f);
        scrollBar.handleRect           = scrollBarHandle.GetComponent <RectTransform>();
        scrollBar.handleRect.offsetMin = Vector2.zero;
        scrollBar.handleRect.offsetMax = Vector2.zero;

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

        // List of quests
        int        offset = 5;
        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();

            tb = new TextButton(new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 5, 1.2f),
                                new StringKey("val", "INDENT", translation), delegate { Selection(key); }, Color.black, offset);
            tb.button.GetComponent <UnityEngine.UI.Text>().fontSize   = UIScaler.GetSmallFont();
            tb.button.GetComponent <UnityEngine.UI.Text>().material   = (Material)Resources.Load("Fonts/FontMaterial");
            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;
        }
        scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, (offset - 5) * UIScaler.GetPixelsPerUnit());

        // 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());
    }
Exemple #16
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);
        }
Exemple #17
0
        // Draw monster if in scroll range (offset is scroll position)
        public void Draw(int offset)
        {
            // Check if in scroll range
            if (index < offset)
            {
                return;
            }
            if (index > offset + 4)
            {
                return;
            }

            GameObject mImg = new GameObject("monsterImg" + m.monsterData.name);

            mImg.tag = Game.MONSTERS;
            mImg.transform.SetParent(game.uICanvas.transform);

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

            trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, (3.75f + ((index - offset) * 4.5f)) * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());
            trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Right, 0.25f * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());
            mImg.AddComponent <CanvasRenderer>();

            icon        = mImg.AddComponent <UnityEngine.UI.Image>();
            icon.sprite = iconSprite;
            icon.rectTransform.sizeDelta = new Vector2(monsterSize * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());

            UnityEngine.UI.Button button = mImg.AddComponent <UnityEngine.UI.Button>();
            button.interactable = true;
            button.onClick.AddListener(delegate { MonsterDiag(); });

            iconFrame = null;
            if (game.gameType is D2EGameType)
            {
                icon.rectTransform.sizeDelta = new Vector2(monsterSize * UIScaler.GetPixelsPerUnit() * 0.83f, monsterSize * UIScaler.GetPixelsPerUnit() * 0.83f);
                GameObject mImgFrame = new GameObject("monsterFrame" + m.monsterData.name);
                mImgFrame.tag = Game.MONSTERS;
                mImgFrame.transform.SetParent(game.uICanvas.transform);

                RectTransform transFrame = mImgFrame.AddComponent <RectTransform>();
                transFrame.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, (3.75f + ((index - offset) * 4.5f)) * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());
                transFrame.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Right, 0.25f * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());
                mImgFrame.AddComponent <CanvasRenderer>();

                iconFrame        = mImgFrame.AddComponent <UnityEngine.UI.Image>();
                iconFrame.sprite = frameSprite;
                iconFrame.rectTransform.sizeDelta = new Vector2(monsterSize * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());

                UnityEngine.UI.Button buttonFrame = mImgFrame.AddComponent <UnityEngine.UI.Button>();
                buttonFrame.interactable = true;
                buttonFrame.onClick.AddListener(delegate { MonsterDiag(); });

                if (m.GetHealth() != 0)
                {
                    TextButton tb = new TextButton(
                        new Vector2(UIScaler.GetRight(-2.25f), 5.75f + ((index - offset) * 4.5f)), new Vector2(2, 2),
                        new StringKey(null, m.GetHealth().ToString(), false),
                        delegate { MonsterDiag(); }, Color.red);
                    tb.ApplyTag(Game.MONSTERS);
                }
            }

            iconDupe = null;
            if (duplicateSprite != null)
            {
                GameObject mImgDupe = new GameObject("monsterDupe" + m.monsterData.name);
                mImgDupe.tag = Game.MONSTERS;
                mImgDupe.transform.SetParent(game.uICanvas.transform);

                RectTransform dupeFrame = mImgDupe.AddComponent <RectTransform>();
                dupeFrame.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, ((monsterSize / 2f) + 3.75f + ((index - offset) * 4.5f)) * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit() / 2f);
                dupeFrame.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Right, 0.25f * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit() / 2f);
                mImgDupe.AddComponent <CanvasRenderer>();

                iconDupe        = mImgDupe.AddComponent <UnityEngine.UI.Image>();
                iconDupe.sprite = duplicateSprite;
                iconDupe.rectTransform.sizeDelta = new Vector2(monsterSize * UIScaler.GetPixelsPerUnit() / 2f, monsterSize * UIScaler.GetPixelsPerUnit() / 2f);

                UnityEngine.UI.Button buttonDupe = mImgDupe.AddComponent <UnityEngine.UI.Button>();
                buttonDupe.interactable = true;
                buttonDupe.onClick.AddListener(delegate { MonsterDiag(); });
            }

            Update();
        }
Exemple #18
0
    // Draw the expansions on the screen, highlighting those that are enabled
    public void Update()
    {
        // Clean up
        Destroyer.Dialog();
        // Initialise selected list
        selected = new List <string>();

        // Fetch which packs are selected from the current config (items under [Packs])
        Dictionary <string, string> setPacks = game.config.data.Get(game.gameType.TypeName() + "Packs");

        if (setPacks != null)
        {
            foreach (KeyValuePair <string, string> kv in setPacks)
            {
                // As packs are just a list, only the key is used, value is empty
                selected.Add(kv.Key);
            }
        }

        // Draw a header
        DialogBox db = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 2), "Select Expansion Content");

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

        // Location for first pack
        float x = 1;
        float y = 4;

        TextButton tb;

        // Draw all packs to the screen
        // Note this is currently unordered
        foreach (ContentData.ContentPack cp in game.cd.allPacks)
        {
            // If the id is "" this is base content and can be ignored
            if (cp.id.Length > 0)
            {
                string id = cp.id;

                // Create a sprite with the pack's image
                Texture2D tex    = ContentData.FileToTexture(cp.image);
                Sprite    sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.zero, 1);

                // Draw normally if selected, dark if not
                if (selected.Contains(id))
                {
                    tb = new TextButton(new Vector2(x, y), new Vector2(6, 6), "", delegate { Unselect(id); });
                    tb.background.GetComponent <UnityEngine.UI.Image>().sprite = sprite;
                    tb.background.GetComponent <UnityEngine.UI.Image>().color  = Color.white;
                }
                else
                {
                    tb = new TextButton(new Vector2(x, y), new Vector2(6, 6), "", delegate { Select(id); }, new Color(0.3f, 0.3f, 0.3f));
                    tb.background.GetComponent <UnityEngine.UI.Image>().sprite = sprite;
                    tb.background.GetComponent <UnityEngine.UI.Image>().color  = new Color(0.3f, 0.3f, 0.3f);
                }
                // Move to next on the right
                x += 7;

                // Check to move down to next row
                if (x > UIScaler.GetRight(-7))
                {
                    x  = 1;
                    y += 7;
                }
            }
        }

        // Button for back to main menu
        tb = new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), "Back", delegate { Destroyer.MainMenu(); }, Color.red);
        tb.SetFont(game.gameType.GetHeaderFont());
    }
        public QuestDetailsScreen(QuestData.Quest q)
        {
            Game game = Game.Get();

            LocalizationRead.AddDictionary("qst", q.localizationDict);
            // 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, 0.5f, UIScaler.GetWidthUnits() - 4, 3);
            ui.SetText(q.name);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetLargeFont());

            // Draw Image
            if (q.image.Length > 0)
            {
                ui = new UIElement();
                ui.SetLocation(UIScaler.GetHCenter(-20), 4, 8, 8);
                ui.SetImage(ContentData.FileToTexture(Path.Combine(q.path, q.image)));
                new UIElementBorder(ui);
            }

            // Draw Description
            ui = new UIElement();
            float height = ui.GetStringHeight(q.description, 30);

            if (height > 25)
            {
                height = 25;
            }
            ui.SetLocation(UIScaler.GetHCenter(-7), 15 - (height / 2), 30, height);
            ui.SetText(q.description);
            new UIElementBorder(ui);

            // Draw authors
            ui     = new UIElement();
            height = ui.GetStringHeight(q.authors, 14);
            if (height > 25)
            {
                height = 25;
            }
            ui.SetLocation(UIScaler.GetHCenter(-23), 18.5f - (height / 2), 14, height);
            ui.SetText(q.authors);
            new UIElementBorder(ui);

            // Difficulty
            if (q.difficulty != 0)
            {
                ui = new UIElement();
                ui.SetLocation(UIScaler.GetHCenter(-13), 27, 11, 1);
                ui.SetText(new StringKey("val", "DIFFICULTY"));
                string symbol = "*";
                if (game.gameType is MoMGameType)
                {
                    symbol = new StringKey("val", "ICON_SUCCESS_RESULT").Translate();
                }
                ui = new UIElement();
                ui.SetLocation(UIScaler.GetHCenter(-13), 28, 11, 2);
                ui.SetText(symbol + symbol + symbol + symbol + symbol);
                ui.SetFontSize(UIScaler.GetMediumFont());
                ui = new UIElement();
                ui.SetLocation(UIScaler.GetHCenter(-10.95f) + (q.difficulty * 6.9f), 28, (1 - q.difficulty) * 6.9f, 2);
                ui.SetBGColor(new Color(0, 0, 0, 0.7f));
            }

            // Duration
            if (q.lengthMax != 0)
            {
                ui = new UIElement();
                ui.SetLocation(UIScaler.GetHCenter(2), 27, 11, 1);
                ui.SetText(new StringKey("val", "DURATION"));

                ui = new UIElement();
                ui.SetLocation(UIScaler.GetHCenter(2), 28, 4, 2);
                ui.SetText(q.lengthMin.ToString());
                ui.SetFontSize(UIScaler.GetMediumFont());

                ui = new UIElement();
                ui.SetLocation(UIScaler.GetHCenter(6.5f), 28, 2, 2);
                ui.SetText("-");
                ui.SetFontSize(UIScaler.GetMediumFont());

                ui = new UIElement();
                ui.SetLocation(UIScaler.GetHCenter(9), 28, 4, 2);
                ui.SetText(q.lengthMax.ToString());
                ui.SetFontSize(UIScaler.GetMediumFont());
            }

            // DELETE button (only for archive, directory might be edited by user)
            if (Path.GetExtension(Path.GetFileName(q.path)) == ".valkyrie")
            {
                ui = new UIElement();
                ui.SetLocation(UIScaler.GetRight(-8.5f), 0.5f, 8, 2);
                ui.SetText(CommonStringKeys.DELETE, Color.grey);
                ui.SetFont(game.gameType.GetHeaderFont());
                ui.SetFontSize(UIScaler.GetMediumFont());
                ui.SetButton(delegate { Delete(q); });
                new UIElementBorder(ui, Color.grey);
            }

            ui = new UIElement();
            ui.SetLocation(0.5f, UIScaler.GetBottom(-2.5f), 8, 2);
            ui.SetText(CommonStringKeys.BACK, Color.red);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(Cancel);
            new UIElementBorder(ui, Color.red);

            ui = new UIElement();
            ui.SetLocation(UIScaler.GetRight(-8.5f), UIScaler.GetBottom(-2.5f), 8, 2);
            ui.SetText(new StringKey("val", "START"), Color.green);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(delegate { Start(q); });
            new UIElementBorder(ui, Color.green);
        }
    // 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());
    }
        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());

            // error message if stats are not available
            if (game.stats.error_download)
            {
                float error_string_width = 0;
                ui = new UIElement();
                if (game.stats.error_download_description == "ERROR NETWORK")
                {
                    StringKey STATS_ERROR_NETWORK = new StringKey("val", "STATS_ERROR_NETWORK");
                    ui.SetText(STATS_ERROR_NETWORK, Color.red);
                    error_string_width = ui.GetStringWidth(STATS_ERROR_NETWORK);
                }
                else
                {
                    StringKey STATS_ERROR_HTTP = new StringKey("val", "STATS_ERROR_HTTP", game.stats.error_download_description);
                    ui.SetText(STATS_ERROR_HTTP, Color.red);
                    error_string_width = ui.GetStringWidth(STATS_ERROR_HTTP);
                }
                ui.SetLocation(UIScaler.GetHCenter() - (error_string_width / 2f), UIScaler.GetBottom(-3f), error_string_width, 2.4f);
                ui.SetTextAlignment(TextAnchor.MiddleCenter);
                ui.SetBGColor(Color.clear);
            }

            // error message if stats are not available
            if (game.stats.download_ongoing)
            {
                float ongoing_string_width = 0;
                ui = new UIElement();
                StringKey STATS_DOWNLOAD_ONGOING = new StringKey("val", "STATS_DOWNLOAD_ONGOING");
                ui.SetText(STATS_DOWNLOAD_ONGOING, Color.white);
                ongoing_string_width = ui.GetStringWidth(STATS_DOWNLOAD_ONGOING);
                ui.SetLocation(UIScaler.GetHCenter() - (ongoing_string_width / 2f), UIScaler.GetBottom(-3f), ongoing_string_width, 2.4f);
                ui.SetTextAlignment(TextAnchor.MiddleCenter);
                ui.SetBGColor(Color.clear);
            }

            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.AddDictionary("qst", 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.6f);
                    ui.SetBGColor(Color.white);
                    ui.SetButton(delegate { Selection(key); });
                    offset += 0.05f;
                    new UIElementBorder(ui, Color.grey);

                    // Draw Image
                    ui = new UIElement(scrollArea.GetScrollTransform());
                    ui.SetLocation(1, offset, 3.5f, 3.5f);
                    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)));
                    }

                    // Quest name
                    ui = new UIElement(scrollArea.GetScrollTransform());
                    ui.SetBGColor(Color.clear);
                    ui.SetLocation(5f, offset - 0.2f, UIScaler.GetWidthUnits() - 8, 2.5f);
                    ui.SetTextPadding(0.5f);
                    ui.SetText(translation, Color.black);
                    ui.SetButton(delegate { Selection(key); });
                    ui.SetTextAlignment(TextAnchor.MiddleLeft);
                    ui.SetFontSize(Mathf.RoundToInt(UIScaler.GetSmallFont() * 1.4f));
                    ui.SetFont(game.gameType.GetHeaderFont());

                    // Duration
                    if (q.Value.lengthMax != 0)
                    {
                        ui = new UIElement(scrollArea.GetScrollTransform());
                        ui.SetLocation(6.5f, offset + 2.3f, 4, 1);
                        ui.SetText(new StringKey("val", "DURATION"), Color.black);
                        ui.SetButton(delegate { Selection(key); });
                        ui.SetTextAlignment(TextAnchor.MiddleLeft);
                        ui.SetBGColor(Color.clear);

                        ui = new UIElement(scrollArea.GetScrollTransform());
                        ui.SetLocation(10.5f, offset + 2.3f, 5, 1);
                        ui.SetText(q.Value.lengthMin + "  -  " + q.Value.lengthMax, Color.black);
                        ui.SetButton(delegate { Selection(key); });
                        ui.SetTextAlignment(TextAnchor.MiddleLeft);
                        ui.SetBGColor(Color.clear);
                    }

                    // Difficulty
                    if (q.Value.difficulty != 0)
                    {
                        ui = new UIElement(scrollArea.GetScrollTransform());
                        ui.SetLocation(UIScaler.GetHCenter() - 5.5f, offset + 2.3f, 6, 1);
                        ui.SetText(new StringKey("val", "DIFFICULTY"), Color.black);
                        ui.SetButton(delegate { Selection(key); });
                        ui.SetTextAlignment(TextAnchor.MiddleRight);
                        ui.SetBGColor(Color.clear);

                        string symbol = "π"; // will
                        if (game.gameType is MoMGameType)
                        {
                            symbol = new StringKey("val", "ICON_SUCCESS_RESULT").Translate();
                        }
                        ui = new UIElement(scrollArea.GetScrollTransform());
                        ui.SetLocation(UIScaler.GetHCenter(), offset + 1.8f, 9, 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.GetHCenter() + 1.05f + (q.Value.difficulty * 6.9f), offset + 1.8f, (1 - q.Value.difficulty) * 6.9f, 1.6f);
                        ui.SetBGColor(new Color(1, 1, 1, 0.7f));
                        ui.SetButton(delegate { Selection(key); });
                    }

                    // Statistics
                    string filename = Path.GetFileName(key).ToLower();
                    if (game.stats != null && game.stats.scenarios_stats != null && game.stats.scenarios_stats.ContainsKey(filename))
                    {
                        ScenarioStats q_stats   = game.stats.scenarios_stats[filename];
                        int           win_ratio = (int)(q_stats.scenario_avg_win_ratio * 100);

                        StringKey STATS_AVERAGE_WIN_RATIO    = new StringKey("val", "STATS_AVERAGE_WIN_RATIO", win_ratio);
                        StringKey STATS_NO_AVERAGE_WIN_RATIO = new StringKey("val", "STATS_NO_AVERAGE_WIN_RATIO", win_ratio);
                        StringKey STATS_NB_USER_REVIEWS      = new StringKey("val", "STATS_NB_USER_REVIEWS", q_stats.scenario_play_count);
                        StringKey STATS_AVERAGE_DURATION     = new StringKey("val", "STATS_AVERAGE_DURATION", (int)(q_stats.scenario_avg_duration));
                        StringKey STATS_NO_AVERAGE_DURATION  = new StringKey("val", "STATS_NO_AVERAGE_DURATION");

                        //  rating
                        string symbol = "★";
                        if (game.gameType is MoMGameType)
                        {
                            symbol = new StringKey("val", "ICON_TENTACLE").Translate();
                        }
                        float rating           = q_stats.scenario_avg_rating / 10;
                        float score_text_width = 0;

                        ui = new UIElement(scrollArea.GetScrollTransform());

                        ui.SetText(symbol + symbol + symbol + symbol + symbol, Color.black);
                        score_text_width = ui.GetStringWidth(symbol + symbol + symbol + symbol + symbol, (int)System.Math.Round(UIScaler.GetMediumFont() * 1.4f)) + 1;
                        ui.SetLocation(UIScaler.GetRight(-12f), offset + 0.6f, score_text_width, 2);
                        ui.SetBGColor(Color.clear);
                        ui.SetFontSize((int)System.Math.Round(UIScaler.GetMediumFont() * 1.4f));
                        ui.SetTextAlignment(TextAnchor.MiddleLeft);
                        ui.SetButton(delegate { Selection(key); });

                        ui = new UIElement(scrollArea.GetScrollTransform());
                        ui.SetLocation(UIScaler.GetRight(-12) + (rating * (score_text_width - 1)), offset + 0.6f, (1 - rating) * score_text_width, 2);
                        ui.SetBGColor(new Color(1, 1, 1, 0.7f));
                        ui.SetButton(delegate { Selection(key); });

                        //  Number of user reviews
                        float user_review_text_width = 0;
                        ui = new UIElement(scrollArea.GetScrollTransform());
                        user_review_text_width = ui.GetStringWidth(STATS_NB_USER_REVIEWS, UIScaler.GetSmallFont()) + 1;
                        ui.SetText(STATS_NB_USER_REVIEWS, Color.black);
                        ui.SetLocation(UIScaler.GetRight(-12) + (score_text_width / 2) - (user_review_text_width / 2), offset + 2.3f, user_review_text_width, 1);
                        ui.SetTextAlignment(TextAnchor.MiddleLeft);
                        ui.SetBGColor(Color.clear);
                        ui.SetFontSize(UIScaler.GetSmallFont());
                        ui.SetButton(delegate { Selection(key); });

                        if (q_stats.scenario_avg_duration > 0 || win_ratio >= 0)
                        {
                            // Additional information in Grey frame
                            ui = new UIElement(scrollArea.GetScrollTransform());
                            ui.SetLocation(3.5f + 1f, offset + 3.6f, UIScaler.GetWidthUnits() - 4.9f - 3.5f - 0.05f, 1.2f);
                            ui.SetBGColor(Color.grey);
                            ui.SetButton(delegate { Selection(key); });

                            //  average duration
                            ui = new UIElement(scrollArea.GetScrollTransform());
                            ui.SetLocation(5f, offset + 3.8f, 14, 1);
                            if (q_stats.scenario_avg_duration > 0)
                            {
                                ui.SetText(STATS_AVERAGE_DURATION, Color.white);
                            }
                            else
                            {
                                ui.SetText(STATS_NO_AVERAGE_DURATION, Color.white);
                            }
                            ui.SetTextAlignment(TextAnchor.MiddleLeft);
                            ui.SetBGColor(Color.clear);
                            ui.SetButton(delegate { Selection(key); });

                            //  average win ratio
                            ui = new UIElement(scrollArea.GetScrollTransform());
                            ui.SetLocation(UIScaler.GetHCenter() - 5.5f, offset + 3.8f, 15, 1);
                            if (win_ratio >= 0)
                            {
                                ui.SetText(STATS_AVERAGE_WIN_RATIO, Color.white);
                            }
                            else
                            {
                                ui.SetText(STATS_NO_AVERAGE_WIN_RATIO, Color.white);
                            }
                            ui.SetBGColor(Color.clear);
                            ui.SetTextAlignment(TextAnchor.MiddleCenter);
                            ui.SetButton(delegate { Selection(key); });

                            offset += 1.4f;
                        }
                    }

                    offset += 4.5f;
                }
            }

            // 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.AddDictionary("qst", 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);
        }
Exemple #22
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());
        }
Exemple #23
0
        // Create a menu which will take up the whole screen and have options.  All items are dialog for destruction.
        public MainMenuScreen()
        {
            // This will destroy all, because we shouldn't have anything left at the main menu
            Destroyer.Destroy();
            Game game = Game.Get();

            List <string> music = new List <string>();

            foreach (AudioData ad in game.cd.audio.Values)
            {
                if (ad.ContainsTrait("menu"))
                {
                    music.Add(ad.file);
                }
            }
            game.audioControl.PlayDefaultQuestMusic(music);

            // Name.  Should this be the banner, or better to print Valkyrie with the game font?
            UIElement ui = new UIElement();

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

            // Version type : alpha / beta should be displayed
            if (Game.Get().version.EndsWith("a"))
            {
                ui = new UIElement();
                ui.SetLocation(UIScaler.GetRight(-6), 1, 6, 3);
                ui.SetText("alpha version");
                ui.SetTextAlignment(TextAnchor.MiddleLeft);
                ui.SetFontSize(UIScaler.GetMediumFont());
            }
            if (Game.Get().version.EndsWith("b"))
            {
                ui = new UIElement();
                ui.SetLocation(UIScaler.GetRight(-6), 1, 6, 3);
                ui.SetText("beta version");
                ui.SetTextAlignment(TextAnchor.MiddleLeft);
                ui.SetFontSize(UIScaler.GetMediumFont());
            }

            // Button for start quest/scenario
            ui = new UIElement();
            ui.SetLocation((UIScaler.GetWidthUnits() - ButtonWidth) / 2, 5, ButtonWidth, 2);
            ui.SetText(START_QUEST);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(Start);
            ui.SetBGColor(new Color(0, 0.03f, 0f));
            new UIElementBorder(ui);

            ui = new UIElement();
            ui.SetLocation((UIScaler.GetWidthUnits() - ButtonWidth) / 2, 8, ButtonWidth, 2);
            if (SaveManager.SaveExists())
            {
                ui.SetText(LOAD_QUEST);
                ui.SetButton(delegate { new SaveSelectScreen(); });
                ui.SetBGColor(new Color(0, 0.03f, 0f));
                new UIElementBorder(ui);
            }
            else
            {
                ui.SetText(LOAD_QUEST, Color.grey);
                new UIElementBorder(ui, Color.grey);
            }
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());

            // Content selection page
            ui = new UIElement();
            ui.SetLocation((UIScaler.GetWidthUnits() - ButtonWidth) / 2, 11, ButtonWidth, 2);
            ui.SetText(SELECT_CONTENT);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(Content);
            ui.SetBGColor(new Color(0, 0.03f, 0f));
            new UIElementBorder(ui);

            // Quest/Scenario editor
            ui = new UIElement();
            ui.SetLocation((UIScaler.GetWidthUnits() - ButtonWidth) / 2, 14, ButtonWidth, 2);
            ui.SetText(new StringKey("val", "QUEST_NAME_EDITOR", game.gameType.QuestName()));
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(Editor);
            ui.SetBGColor(new Color(0, 0.03f, 0f));
            new UIElementBorder(ui);

            // About page (managed in this class)
            ui = new UIElement();
            ui.SetLocation((UIScaler.GetWidthUnits() - ButtonWidth) / 2, 17, ButtonWidth, 2);
            ui.SetText(ABOUT);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(About);
            ui.SetBGColor(new Color(0, 0.03f, 0f));
            new UIElementBorder(ui);

            // Configuration menu
            ui = new UIElement();
            ui.SetLocation((UIScaler.GetWidthUnits() - ButtonWidth) / 2, 20, ButtonWidth, 2);
            ui.SetText(OPTIONS);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(Config);
            ui.SetBGColor(new Color(0, 0.03f, 0f));
            new UIElementBorder(ui);

            // Exit Valkyrie
            ui = new UIElement();
            ui.SetLocation((UIScaler.GetWidthUnits() - ButtonWidth) / 2, 23, ButtonWidth, 2);
            ui.SetText(CommonStringKeys.EXIT);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(Exit);
            ui.SetBGColor(new Color(0, 0.03f, 0f));
            new UIElementBorder(ui);
        }
        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),
                new StringKey("val", "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), StringKey.NULL);
            db.AddBorder();
            db.background.AddComponent <UnityEngine.UI.Mask>();
            UnityEngine.UI.ScrollRect scrollRect = db.background.AddComponent <UnityEngine.UI.ScrollRect>();

            GameObject scrollBarObj = new GameObject("scrollbar");

            scrollBarObj.transform.parent = db.background.transform;
            RectTransform scrollBarRect = scrollBarObj.AddComponent <RectTransform>();

            scrollBarRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 21 * UIScaler.GetPixelsPerUnit());
            scrollBarRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, (UIScaler.GetWidthUnits() - 3f) * UIScaler.GetPixelsPerUnit(), 1 * UIScaler.GetPixelsPerUnit());
            UnityEngine.UI.Scrollbar scrollBar = scrollBarObj.AddComponent <UnityEngine.UI.Scrollbar>();
            scrollBar.direction          = UnityEngine.UI.Scrollbar.Direction.BottomToTop;
            scrollRect.verticalScrollbar = scrollBar;

            GameObject scrollBarHandle = new GameObject("scrollbarhandle");

            scrollBarHandle.transform.parent = scrollBarObj.transform;
            //RectTransform scrollBarHandleRect = scrollBarHandle.AddComponent<RectTransform>();
            scrollBarHandle.AddComponent <UnityEngine.UI.Image>();
            scrollBarHandle.GetComponent <UnityEngine.UI.Image>().color = new Color(0.7f, 0.7f, 0.7f);
            scrollBar.handleRect           = scrollBarHandle.GetComponent <RectTransform>();
            scrollBar.handleRect.offsetMin = Vector2.zero;
            scrollBar.handleRect.offsetMax = Vector2.zero;

            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.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
                    tb = new TextButton(
                        new Vector2(2, offset),
                        new Vector2(UIScaler.GetWidthUnits() - 5, 1.2f),
                        new StringKey("val", "INDENT", translation),
                        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.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
                    db = new DialogBox(
                        new Vector2(2, offset),
                        new Vector2(UIScaler.GetWidthUnits() - 5, 1.2f),
                        new StringKey("val", "INDENT", translation),
                        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.GetLoadedPackIDs()))
                    {
                        db = new DialogBox(
                            new Vector2(4, offset),
                            new Vector2(UIScaler.GetWidthUnits() - 9, 1.2f),
                            // TODO: Expansion names should be keys too
                            new StringKey("val", "REQUIRES_EXPANSION", 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),
                CommonStringKeys.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());
        }
Exemple #25
0
        // Create a menu which will take up the whole screen and have options.  All items are dialog for destruction.
        public MainMenuScreen()
        {
            // This will destroy all, because we shouldn't have anything left at the main menu
            Destroyer.Destroy();
            Game game = Game.Get();

            List <string> music = new List <string>();

            foreach (AudioData ad in game.cd.Values <AudioData>())
            {
                if (ad.ContainsTrait("menu"))
                {
                    music.Add(ad.file);
                }
            }
            game.audioControl.PlayDefaultQuestMusic(music);

            // Background image.
            UIElement bg = new UIElement();

            bg.SetLocation(0, 0, UIScaler.GetWidthUnits(), UIScaler.GetHeightUnits());
            bg.SetImage(Resources.Load($"sprites/GameBackground{game.gameType.TypeName()}") as Texture2D, true, AspectRatioFitter.AspectMode.EnvelopeParent);

            // Name.  Should this be the banner, or better to print Valkyrie with the game font?
            UIElement ui = new UIElement();

            ui.SetLocation(2, 1, UIScaler.GetWidthUnits() - 4, 3);
            ui.SetText("Valkyrie");
            ui.SetBGColor(Color.clear);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetLargeFont());
            ui.SetTextOutline(Color.black, 1);


            // Version type : alpha / beta should be displayed
            if (Game.Get().version.EndsWith("a"))
            {
                ui = new UIElement();
                ui.SetLocation(UIScaler.GetRight(-6), 1, 6, 3);
                ui.SetText("alpha version");
                ui.SetTextAlignment(TextAnchor.MiddleLeft);
                ui.SetFontSize(UIScaler.GetMediumFont());
                ui.SetButton(delegate { TestCrash(); });
            }
            if (Game.Get().version.EndsWith("b"))
            {
                ui = new UIElement();
                ui.SetLocation(UIScaler.GetRight(-6), 1, 6, 3);
                ui.SetText("beta version");
                ui.SetTextAlignment(TextAnchor.MiddleLeft);
                ui.SetFontSize(UIScaler.GetMediumFont());
                ui.SetButton(delegate { TestCrash(); });
            }

            float menuButtonsX = UIScaler.GetWidthUnits() * 0.05f;

            // Button for start quest/scenario
            ui = new UIElement();
            ui.SetLocation(menuButtonsX, 5, ButtonWidth, 2);
            ui.SetText(START_QUEST);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(Start);
            ui.SetBGColor(BUTTON_BG_COLOR);
            new UIElementBorder(ui, BUTTON_BORDER_COLOR_ACTIVE);

            ui = new UIElement();
            ui.SetLocation(menuButtonsX, 8, ButtonWidth, 2);
            ui.SetBGColor(BUTTON_BG_COLOR);
            if (SaveManager.SaveExists())
            {
                ui.SetText(LOAD_QUEST);
                ui.SetButton(delegate { new SaveSelectScreen(); });
                new UIElementBorder(ui, BUTTON_BORDER_COLOR_ACTIVE);
            }
            else
            {
                ui.SetText(LOAD_QUEST, Color.grey);
                new UIElementBorder(ui, BUTTON_BORDER_COLOR_INACTIVE);
            }
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());

            // Content selection page
            ui = new UIElement();
            ui.SetLocation(menuButtonsX, 11, ButtonWidth, 2);
            ui.SetText(SELECT_CONTENT);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(Content);
            ui.SetBGColor(BUTTON_BG_COLOR);
            new UIElementBorder(ui, BUTTON_BORDER_COLOR_ACTIVE);

            // Quest/Scenario editor
            ui = new UIElement();
            ui.SetLocation(menuButtonsX, 14, ButtonWidth, 2);
            ui.SetText(new StringKey("val", "QUEST_NAME_EDITOR", game.gameType.QuestName()));
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(Editor);
            ui.SetBGColor(BUTTON_BG_COLOR);
            new UIElementBorder(ui, BUTTON_BORDER_COLOR_ACTIVE);

            // About page (managed in this class)
            ui = new UIElement();
            ui.SetLocation(menuButtonsX, 17, ButtonWidth, 2);
            ui.SetText(ABOUT);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(About);
            ui.SetBGColor(BUTTON_BG_COLOR);
            new UIElementBorder(ui, BUTTON_BORDER_COLOR_ACTIVE);

            // Configuration menu
            ui = new UIElement();
            ui.SetLocation(menuButtonsX, 20, ButtonWidth, 2);
            ui.SetText(OPTIONS);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(Config);
            ui.SetBGColor(BUTTON_BG_COLOR);
            new UIElementBorder(ui, BUTTON_BORDER_COLOR_ACTIVE);

            // Exit Valkyrie
            ui = new UIElement();
            ui.SetLocation(menuButtonsX, 23, ButtonWidth, 2);
            ui.SetText(CommonStringKeys.EXIT);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(Exit);
            ui.SetBGColor(BUTTON_BG_COLOR);
            new UIElementBorder(ui, BUTTON_BORDER_COLOR_ACTIVE);
        }
Exemple #26
0
    // Draw items
    public virtual void CreateWindow()
    {
        Game game = Game.Get();
        // Count the monster number
        int index = 0;

        for (int i = 0; i < game.quest.monsters.Count; i++)
        {
            if (game.quest.monsters[i] == monster)
            {
                index = i;
            }
        }

        // Work out where on the screen to display
        float offset = (index + 0.1f - game.monsterCanvas.offset) * (MonsterCanvas.monsterSize + 0.5f);

        if (GameObject.FindGameObjectWithTag(Game.ACTIVATION) != null)
        {
            offset += 2.8f;
        }

        UIElement ui = new UIElement();

        ui.SetLocation(UIScaler.GetRight(-10.5f - MonsterCanvas.monsterSize), offset, 10, 2);
        ui.SetText(INFORMATION);
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetButton(Info);
        new UIElementBorder(ui);
        offset += 2.5f;
        if (GameObject.FindGameObjectWithTag(Game.ACTIVATION) == null)
        {
            ui = new UIElement();
            ui.SetLocation(UIScaler.GetRight(-10.5f - MonsterCanvas.monsterSize), offset, 10, 2);
            ui.SetText(FORCE_ACTIVATE);
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(Activate);
            new UIElementBorder(ui);
            offset += 2.5f;

            ui = new UIElement();
            ui.SetLocation(UIScaler.GetRight(-10.5f - MonsterCanvas.monsterSize), offset, 10, 2);
            ui.SetText(DEFEATED);
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(Defeated);
            new UIElementBorder(ui);
            offset += 2.5f;
            if (monster.unique)
            {
                // If there is a unique option the offset needs to be increased
                ui = new UIElement();
                ui.SetLocation(UIScaler.GetRight(-10.5f - MonsterCanvas.monsterSize), offset, 10, 3);
                ui.SetText(UNIQUE_DEFEATED);
                ui.SetFontSize(UIScaler.GetMediumFont());
                ui.SetButton(UniqueDefeated);
                new UIElementBorder(ui);
                offset += 3.5f;
            }
        }
        // FIXME: This doesn't fit if there is a unique monster in the last space
        ui = new UIElement();
        ui.SetLocation(UIScaler.GetRight(-10.5f - MonsterCanvas.monsterSize), offset, 10, 2);
        ui.SetText(CommonStringKeys.CANCEL);
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetButton(OnCancel);
        new UIElementBorder(ui);
    }
    public void RenderPage(int heroId, int offset)
    {
        foreach (GameObject go in GameObject.FindGameObjectsWithTag("dialog"))
        {
            Object.Destroy(go);
        }

        Game game = Game.Get();

        float x = 8;
        float y = 5 - (5f * offset);

        if (y > 4)
        {
            HeroSelectButton(new Vector2(x, y), null, heroId);
        }

        List <string> heroList = new List <string>(game.cd.heros.Keys);

        heroList.Sort();

        bool prevPage = false;
        bool nextPage = false;

        foreach (string hero in heroList)
        {
            x += 5f;
            if (x > UIScaler.GetRight(-13))
            {
                x  = 8;
                y += 5f;
            }

            if (y >= 24)
            {
                nextPage = true;
            }
            else if (y < 4)
            {
                prevPage = true;
            }
            else
            {
                bool disabled = false;
                foreach (Quest.Hero hIt in game.quest.heroes)
                {
                    if ((hIt.heroData == game.cd.heros[hero]) && (hIt.id != heroId))
                    {
                        disabled = true;
                    }
                }
                HeroSelectButton(new Vector2(x, y), game.cd.heros[hero], heroId, disabled);
            }
        }

        if (prevPage || nextPage)
        {
            PrevButton(!prevPage, heroId, offset);
            NextButton(!nextPage, heroId, offset);
        }
    }
Exemple #28
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);
    }
Exemple #29
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
            DialogBox db = new DialogBox(
                new Vector2(8, 1),
                new Vector2(UIScaler.GetWidthUnits() - 16, 3),
                new StringKey("val", "SELECT_CLASS")
                );

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

            // 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;
            }

            TextButton tb = null;

            for (int i = 0; i < heroCount; i++)
            {
                DrawHero(xOffset, i);
                xOffset += 9f;
            }
            // Add a finished button to start the quest
            tb = new TextButton(
                new Vector2(UIScaler.GetRight(-8.5f),
                            UIScaler.GetBottom(-2.5f)),
                new Vector2(8, 2),
                CommonStringKeys.FINISHED,
                delegate { Finished(); },
                Color.green);
            tb.SetFont(game.gameType.GetHeaderFont());
            tb.ApplyTag(Game.HEROSELECT);

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

            cancelSelection.SetFont(game.gameType.GetHeaderFont());
            // Untag as dialog so this isn't cleared away during hero selection
            cancelSelection.ApplyTag(Game.HEROSELECT);
        }