Example #1
0
        void LoadRegularPage()
        {
            //panel
            comicPanel = new Panel();
            comicPanel.AutoSize = true;
            comicPanel.Width = REGULAR_COMIC_PANEL_WIDTH;
            comicPanel.MaximumSize = new Size(REGULAR_COMIC_PANEL_WIDTH, Int32.MaxValue);
            comicPanel.Location = new Point(mainPanel.Width / 2 - comicPanel.Width / 2, REGULAR_COMIC_PANEL_Y_OFFSET);
            comicPanel.BackColor = Color.FromArgb(REGULAR_COMIC_PANEL_COLOUR_R, REGULAR_COMIC_PANEL_COLOUR_G, REGULAR_COMIC_PANEL_COLOUR_B);
            mainPanel.Controls.Add(comicPanel);

            //title
            title = new GrowRich();
            title.Width = REGULAR_PAGE_TITLE_WIDTH;
            title.SelectionAlignment = HorizontalAlignment.Center;
            title.Font = new System.Drawing.Font("Courier New", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            title.Text = page.meta.title;
            comicPanel.Controls.Add(title);
            title.Location = new Point(comicPanel.Width / 2 - title.Width / 2, REGULAR_TITLE_Y_OFFSET);

            //content
            int currentHeight = !Enum.IsDefined(typeof(Writer.FullScreenFlashes), page.number) ? title.Location.Y + title.Height + REGULAR_TITLE_Y_OFFSET : 0;
            if (Parser.IsOpenBound(page.number))
            {
                flash = new WebBrowser();
                comicPanel.Controls.Add(flash);
                InitOpenbound();
                flash.Location = new Point(comicPanel.Width / 2 - flash.Width / 2, currentHeight);
                currentHeight += flash.Height;
                pageContainsFlash = true;
            }
            else
            {
                for (int i = 0; i < page.resources.Count(); i++)
                {
                    if (i == page.resources.Count() - 1 && Parser.Is2x(page.number) && page.resources != page.resources2)
                    {
                        currentHeight -= REGULAR_COMIC_PANEL_BOTTOM_Y_OFFSET;
                        continue;
                    }
                    if (page.resources[i].isInPesterLog)
                        continue;
                    if (!pageContainsFlash &&
                        ((page.number == 8848 || page.number == 8850) //special horizontal scroll
                        || !Parser.IsGif(page.resources[i].originalFileName)))
                    {
                        if (Path.GetExtension(page.resources[i].originalFileName) == ".mp4")
                        {
                            FVideoPlayer = TryInitVLC();
                            if (FVideoPlayer == null)
                                return;
                            var loc = WriteTempResource(ref page.resources[i]);
                            FVideoPlayer.Width = Width;
                            FVideoPlayer.Height = Height;
                            FVideoPlayer.SetMedia(new FileInfo(loc));
                            FVideoPlayer.Play();
                            Controls.Add(FVideoPlayer);
                            currentHeight += 750;
                        }
                        else
                        {
                            flash = new WebBrowser();
                            comicPanel.Controls.Add(flash);
                            InitFlashMovie(flash, page.resources[i]);

                            flash.Location = new Point(comicPanel.Width / 2 - flash.Width / 2, currentHeight);
                            currentHeight += flash.Height;
                            pageContainsFlash = true;
                        }
                       }
                    else if (Parser.IsGif(page.resources[i].originalFileName))
                    {

                        var tempPB = new GifStream();
                        tempPB.loc = new System.IO.MemoryStream(page.resources[i].data);
                        tempPB.gif = new PictureBox();
                        tempPB.gif.Image = Image.FromStream(tempPB.loc);
                        tempPB.gif.Width = tempPB.gif.Image.Width;
                        tempPB.gif.Height = tempPB.gif.Image.Height;
                        tempPB.gif.Location = new Point(comicPanel.Width / 2 - tempPB.gif.Width / 2, currentHeight);
                        comicPanel.Controls.Add(tempPB.gif);
                        currentHeight += tempPB.gif.Height;
                        if (i < page.resources.Count() - 1 || (page.resources[page.resources.Count() - 1].isInPesterLog && i == page.resources.Count() - 1))
                            currentHeight += REGULAR_COMIC_PANEL_BOTTOM_Y_OFFSET;
                        gifs.Add(tempPB);
                    }
                }
            }
            if (!Enum.IsDefined(typeof(Writer.FullScreenFlashes), page.number))
                currentHeight += REGULAR_SPACE_BETWEEN_CONTENT_AND_TEXT;

            //words
            int leftSide;
            if (page.meta.narr != null)
            {
                narrative = new GrowRich();
                narrative.Width = REGULAR_NARRATIVE_WIDTH;
                narrative.DetectUrls = true;
                narrative.SelectionAlignment = HorizontalAlignment.Center;
                narrative.Font = new System.Drawing.Font("Courier New", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                narrative.Text = page.meta.narr.text;
                narrative.ForeColor = System.Drawing.ColorTranslator.FromHtml(page.meta.narr.hexColour);
                var tmpl = narrative;
                if (page.meta.narr.subTexts.Count() != 0)
                    for (int j = 0; j < page.meta.narr.subTexts.Count(); ++j)
                    {
                        if (!page.meta.narr.subTexts[j].isImg && !page.meta.narr.subTexts[j].isLink)
                        {

                            //font change
                            tmpl.Select(page.meta.narr.subTexts[j].begin, page.meta.narr.subTexts[j].length);
                            if (page.meta.narr.subTexts[j].underlined)
                                tmpl.SelectionFont = new System.Drawing.Font("Courier New", 10.5F, System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                            tmpl.SelectionColor = System.Drawing.ColorTranslator.FromHtml(page.meta.narr.subTexts[j].colour);
                        }
                        else if (page.meta.narr.subTexts[j].isLink)
                        {
                            //so since rtf hyperlinks are broken to f**k we'll just improvise
                            var link = new GrowLinkLabel();
                            tmpl.Select(page.meta.narr.subTexts[j].begin, page.meta.narr.subTexts[j].length);
                            link.Text = tmpl.SelectedText;
                            link.Font = narrative.Font;
                            var inlineLink = page.meta.narr.subTexts[j].colour;
                            //for lack of a better place to put this snippet/lazyness'
                            if (page.number == (int)Writer.StoryBoundaries.EOHSB)
                                link.Click += (o, i) => { WakeUpMr((int)Writer.StoryBoundaries.HOMESTUCK_PAGE_ONE); };
                            else
                                link.Click += (o, i) => { System.Diagnostics.Process.Start(inlineLink); };
                            link.Width = narrative.Width;
                            link.Height = narrative.Height;
                            link.TextAlign = ContentAlignment.MiddleCenter;
                            conversations.Add(new LineOrPB(link));
                        }
                        else
                        {
                            //inline image

                            //what needs to happen here is we need to advance the text so that the image can fit in which should just be " " times some factor of the width of the image
                            //for now assume 1space = 10.5 pt = 14px
                            Parser.Resource inlineImg = Array.Find(page.resources, x => x.isInPesterLog == true && x.originalFileName == page.meta.narr.subTexts[j].colour);
                            var tmpPB = new GifStream();
                            tmpPB.loc = new MemoryStream(inlineImg.data);
                            tmpPB.gif = new PictureBox();
                            tmpPB.gif.Image = Image.FromStream(tmpPB.loc);

                            string spaces = "";
                            int needed = tmpPB.gif.Image.Width / 14;
                            for (int k = 0; k < needed; ++k)
                                spaces += " ";

                            tmpl.Text = tmpl.Text.Substring(0, page.meta.narr.subTexts[j].begin) + spaces + tmpl.Text.Substring(page.meta.narr.subTexts[j].begin);

                            //just dispose the picture while we are testing this
                            tmpPB.gif.Dispose();
                            tmpPB.loc.Dispose();

                        }
                    }
                leftSide = comicPanel.Width / 2 - narrative.Width / 2;
                narrative.Location = new Point(leftSide, currentHeight);

                currentHeight += narrative.Height;

                comicPanel.Controls.Add(narrative);

                foreach (var link in conversations)
                {
                    comicPanel.Controls.Add(link.GetControl());
                    link.GetControl().Location = narrative.Location;
                    link.GetControl().BringToFront();
                }
            }
            else
            {
                pesterlog = new Panel();
                pesterlog.AutoSize = true;
                pesterlog.Width = REGULAR_PESTERLOG_WIDTH;
                pesterlog.Height = REGULAR_PESTERLOG_HEIGHT;
                pesterlog.MinimumSize = new Size(REGULAR_PESTERLOG_WIDTH, REGULAR_PESTERLOG_HEIGHT);
                pesterlog.MaximumSize = new Size(REGULAR_PESTERLOG_WIDTH, Int32.MaxValue);
                pesterlog.BorderStyle = BorderStyle.FixedSingle;
                pesterlog.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;

                leftSide = comicPanel.Width / 2 - pesterlog.Width / 2;
                pesterlog.Location = new Point(leftSide, currentHeight);
                comicPanel.Controls.Add(pesterlog);

                pesterHideShow = new Button();
                pesterHideShow.FlatStyle = FlatStyle.Flat;
                pesterHideShow.AutoSize = true;
                pesterHideShow.Font = new System.Drawing.Font("Arial", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                pesterHideShow.Text = "Show " + page.meta.promptType;
                pesterHideShow.Click += pesterHideShow_Click;
                pesterLogVisible = false;
                pesterlog.Controls.Add(pesterHideShow);
                pesterHideShow.Location = new Point(pesterlog.Width / 2 - pesterHideShow.Width / 2, 2);

                pLMaxHeight = currentHeight + REGULAR_SPACE_BETWEEN_CONTENT_AND_TEXT;
                //log lines
                for (int i = 0; i < page.meta.lines.Count(); ++i)
                {
                    if (!page.meta.lines[i].isImg)
                    {
                        var tmpl = new GrowRich();
                        tmpl.Width = REGULAR_PESTERLOG_LINE_WIDTH;
                        tmpl.DetectUrls = true;
                        tmpl.MaximumSize = new Size(tmpl.Width, Int32.MaxValue);
                        tmpl.Font = new System.Drawing.Font("Courier New", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                        tmpl.BackColor = pesterlog.BackColor;   //can't change forecolour otherwise
                        tmpl.ForeColor = System.Drawing.ColorTranslator.FromHtml(page.meta.lines[i].hexColour);
                        tmpl.Text = "";

                        tmpl.Text += page.meta.lines[i].text;

                        if (page.meta.lines[i].subTexts.Count() != 0)
                            for (int j = 0; j < page.meta.lines[i].subTexts.Count(); ++j)
                            {
                                if (!page.meta.lines[i].subTexts[j].isImg && !page.meta.lines[i].subTexts[j].isLink)
                                {

                                    //font change
                                    tmpl.Select(page.meta.lines[i].subTexts[j].begin, page.meta.lines[i].subTexts[j].length);
                                    if (page.meta.lines[i].subTexts[j].underlined)
                                        tmpl.SelectionFont = new System.Drawing.Font("Courier New", 10.5F, System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                                    tmpl.SelectionColor = System.Drawing.ColorTranslator.FromHtml(page.meta.lines[i].subTexts[j].colour);
                                }
                                else if (page.meta.lines[i].subTexts[j].isLink)
                                {

                                    tmpl.Select(page.meta.lines[i].subTexts[j].begin, page.meta.lines[i].subTexts[j].length);
                                    tmpl.DetectUrls = true;
                                    tmpl.AppendText(page.meta.lines[i].subTexts[j].colour);
                                    Debugger.Break();
                                }
                                else
                                {
                                    //inline image

                                    //what needs to happen here is we need to advance the text so that the image can fit in which should just be " " times some factor of the width of the image
                                    //for now assume 1space = 10.5 pt = 14px
                                    Parser.Resource inlineImg = Array.Find(page.resources, x => x.isInPesterLog == true && x.originalFileName == page.meta.lines[i].subTexts[j].colour);
                                    var tmpPB = new GifStream();
                                    tmpPB.loc = new MemoryStream(inlineImg.data);
                                    tmpPB.gif = new PictureBox();
                                    tmpPB.gif.Image = Image.FromStream(tmpPB.loc);

                                    string spaces = "";
                                    int needed = tmpPB.gif.Image.Width / 14;
                                    for (int k = 0; k < needed; ++k)
                                        spaces += " ";

                                    tmpl.Text = tmpl.Text.Substring(0, page.meta.lines[i].subTexts[j].begin) + spaces + tmpl.Text.Substring(page.meta.lines[i].subTexts[j].begin);

                                    //just dispose the picture while we are testing this
                                    tmpPB.gif.Dispose();
                                    tmpPB.loc.Dispose();

                                }
                            }
                        tmpl.Location = new Point(pesterlog.ClientSize.Width / 2 - tmpl.Width / 2, pLMaxHeight - currentHeight);
                        pLMaxHeight += tmpl.Height;
                        conversations.Add(new LineOrPB(tmpl));
                    }
                    else
                    {
                        //find the resource
                        var tmpI = Array.Find(page.resources, x => x.isInPesterLog == true && x.originalFileName == page.meta.lines[i].text);
                        //TODO: Handle image lines ("SHE HAS WHAT????")
                        if (Parser.IsGif(tmpI.originalFileName))
                        {

                            var tempPB = new GifStream();
                            tempPB.loc = new System.IO.MemoryStream(tmpI.data);
                            tempPB.gif = new PictureBox();
                            tempPB.gif.Image = Image.FromStream(tempPB.loc);
                            tempPB.gif.Width = tempPB.gif.Image.Width;
                            tempPB.gif.Height = tempPB.gif.Image.Height;
                            tempPB.gif.Location = new Point(pesterlog.ClientSize.Width / 2 - REGULAR_PESTERLOG_LINE_WIDTH / 2, pLMaxHeight - currentHeight);
                            pLMaxHeight += tempPB.gif.Height;

                            conversations.Add(new LineOrPB(tempPB));
                        }
                        else
                        {
                            //there's problems
                            Debugger.Break(); //then let us bounce
                        }
                    }
                }

                currentHeight += pesterlog.Height;
                pLMinHeight = currentHeight;
                pLMaxHeight += REGULAR_SPACE_BETWEEN_CONTENT_AND_TEXT;
            }

            if (!Enum.IsDefined(typeof(Writer.FullScreenFlashes), page.number))
                currentHeight += REGULAR_SPACE_BETWEEN_CONTENT_AND_TEXT;

            //add 2x fake link

            if (Parser.Is2x(page.number) && page.resources != page.resources2)
            {
                var tempPB = new GifStream();
                tempPB.loc = new System.IO.MemoryStream(page.resources[page.resources.Count() - 1].data);
                tempPB.gif = new PictureBox();
                tempPB.gif.Image = Image.FromStream(tempPB.loc);
                tempPB.gif.Width = tempPB.gif.Image.Width;
                tempPB.gif.Height = tempPB.gif.Image.Height;
                tempPB.gif.Location = new Point(comicPanel.Width / 2 - tempPB.gif.Width / 2, currentHeight);
                comicPanel.Controls.Add(tempPB.gif);
                currentHeight += tempPB.gif.Height;
                gifs.Add(tempPB);
            }

            //next page
            if (page.number < db.lastPage && page.links != null)
            {
                for (int i = 0; i < page.links.Count(); i++)
                {
                    var linkPrefixn = new Label();
                    linkPrefixn.AutoSize = true;
                    linkPrefixn.Font = new System.Drawing.Font("Verdana", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                    linkPrefixn.Text = REGULAR_LINK_PREFIX;
                    linkPrefixn.Location = new Point(leftSide, currentHeight);
                    comicPanel.Controls.Add(linkPrefixn);
                    linkPrefix.Add(linkPrefixn);

                    var nextn = new GrowLinkLabel();
                    nextn.Width = 600;
                    nextn.Font = new System.Drawing.Font("Verdana", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                    nextn.Text = "    " + page.links[i].originalText;
                    nextn.Location = new Point(leftSide, currentHeight);
                    var tmpi = i;   //I really don't know how these labmdas work sometimes
                    if (Enum.IsDefined(typeof(Writer.PasswordPages), page.links[tmpi].pageNumber))
                        nextn.LinkClicked += HandleTereziPassword;
                    else
                        nextn.LinkClicked += (o, z) => { WakeUpMr(page.links[tmpi].pageNumber); };
                    comicPanel.Controls.Add(nextn);
                    next.Add(nextn);

                    linkPrefixn.BringToFront();
                    if (i < page.links.Count() - 1)
                        currentHeight += nextn.Height;
                }
            }

            comicPanel.Height = currentHeight + REGULAR_COMIC_PANEL_BOTTOM_PADDING;

            mainPanel.Height = comicPanel.Height + REGULAR_COMIC_PANEL_Y_OFFSET + REGULAR_COMIC_PANEL_BOTTOM_Y_OFFSET;

            if (page.meta.promptType == "CalibornLog")
                FixNarrativePrompt();

            RemoveControl(pageLoadingProgress);RemoveControl(progressLabel);
        }
Example #2
0
        void LoadCascade()
        {
            //cascade has no comic panel, use the mainPanel
            comicPanel = mainPanel;
            comicPanel.Location = new Point(comicPanel.Location.X, 0);

            //title is part of the flash
            title = null;

            //special header

            var tempPB = new GifStream();
            tempPB.loc = new System.IO.MemoryStream(page.resources[6].data);
            tempPB.gif = new PictureBox();
            tempPB.gif.Image = Image.FromStream(tempPB.loc);
            tempPB.gif.Width = tempPB.gif.Image.Width;
            tempPB.gif.Height = tempPB.gif.Image.Height;
            tempPB.gif.Location = new Point(comicPanel.Width / 2 - tempPB.gif.Width / 2, 0);
            comicPanel.Controls.Add(tempPB.gif);
            gifs.Add(tempPB);

            //*

            //first write the segments
            WriteTempResource(ref page.resources[1]);
            WriteTempResource(ref page.resources[2]);
            WriteTempResource(ref page.resources[3]);
            WriteTempResource(ref page.resources[4]);
            WriteTempResource(ref page.resources[5]);

            flash = new WebBrowser();
            comicPanel.Controls.Add(flash);

            InitFlashMovie(flash, page.resources[0]);
            flash.Location = new Point(comicPanel.Width / 2 - flash.Width / 2, CASCADE_PANEL_Y_OFFSET + REGULAR_PANEL_Y_OFFSET + 40);

            // * */
            pageContainsFlash = true;

            var linkPrefixn = new Label();
            linkPrefixn.AutoSize = true;
            linkPrefixn.Font = new System.Drawing.Font("Verdana", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            linkPrefixn.Text = REGULAR_LINK_PREFIX;
            linkPrefixn.Location = new Point(REGULAR_PANEL_WIDTH / 2  - REGULAR_PESTERLOG_WIDTH/2, flash.Location.Y + flash.Height + 23);
            comicPanel.Controls.Add(linkPrefixn);
            linkPrefix.Add(linkPrefixn);

            var nextn = new GrowLinkLabel();
            nextn.Width = 600;
            nextn.Font = new System.Drawing.Font("Verdana", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            nextn.Text = "    " + page.links[0].originalText;
            nextn.Location = linkPrefixn.Location; //TODO: MAGIC NUMBERS!!!
            nextn.LinkClicked += (o, z) => { WakeUpMr(page.links[0].pageNumber); };
            comicPanel.Controls.Add(nextn);
            next.Add(nextn);

            linkPrefixn.BringToFront();

            mainPanel.Height = flash.Location.Y + flash.Height +
                CASCADE_BOTTOM_Y_OFFSET;

            headerPanel.BringToFront();

            RemoveControl(pageLoadingProgress);RemoveControl(progressLabel);
        }