Ejemplo n.º 1
0
        private void LoadList_SelectedIndexChanged(object sender, EventArgs e)
        {
            string path = LuaAPI.userdata + LoadList.SelectedItem.ToString();

            isVisualNovel    = ifs.GetString(path, "param", "mode") == "VisualNovel";
            GameScenarioFile = ifs.GetString(path, "param", "game");


            if (!isVisualNovel)
            {
                InitObjectsList();

                for (int Iter = 0; Iter < UsSectList.Length; Iter++)
                {
                    UsSectList[Iter].Load(ref ifs, path, Iter);
                }
            }
            else
            {
                UsSectList = new SectionEditon[1];
            }

            UsSectList[0] = new SectionEditon
            {
                Idx             = 0,
                Section         = 0,
                SectionNext     = 0,
                SectionLabel    = 0,
                SectionLabelOld = 0,

                SectionString    = "",
                SectionStringOld = ""
            };
            UsSectList[0].Load(ref ifs, path, 0);

            // Restored LuaTables
            int LayerCount = Convert.ToInt32(ifs.GetString(path, "layer", "count"));

            lua.lua.GetTable("Scene")["Images"] = LayerCount;

            for (int Iter = 0; Iter < LayerCount; Iter++)
            {
                lua.lua.GetTable("Scene")["Image" + Iter.ToString()] = ifs.GetString(path, "layer", "layer" + Iter.ToString());
            }

            lua.SetHook(ifs.GetString(path, "layer", "hook"));
            lua.CallHook();

            LoadList.Visible = false;
            MenuUpdate(false);

            if (isVisualNovel)
            {
                NextScene(true, ref UsSectList[0]);
            }

            MessBox_1.Visible = true;
        }
Ejemplo n.º 2
0
        private void InitObjectsList()
        {
            int ObjCount = Convert.ToInt32(ifs.GetString(LuaAPI.cfg + GameScenarioFile, "objects", "count")) + 1;

            UsableObjects = new PictureBox[ObjCount];
            UsObjScen     = new string[ObjCount];
            UsSectList    = new SectionEditon[ObjCount];

            for (int Iter = 1; Iter < ObjCount; Iter++)
            {
                string ValidIter       = (Iter - 1).ToString();
                string CurrObject      = ifs.GetString(LuaAPI.cfg + GameScenarioFile, "objects", ValidIter + "_scene");
                string CurrObjectImage = LuaAPI.images + ifs.GetString(LuaAPI.cfg + GameScenarioFile, "objects", ValidIter + "_image");

                int SizeH = Convert.ToInt32(ifs.GetString(LuaAPI.cfg + GameScenarioFile, "objects", ValidIter + "_image_h"));
                int SizeW = Convert.ToInt32(ifs.GetString(LuaAPI.cfg + GameScenarioFile, "objects", ValidIter + "_image_w"));

                int PosX = Convert.ToInt32(ifs.GetString(LuaAPI.cfg + GameScenarioFile, "objects", ValidIter + "_image_x"));
                int PosY = Convert.ToInt32(ifs.GetString(LuaAPI.cfg + GameScenarioFile, "objects", ValidIter + "_image_y"));

                // Make object picture
                UsableObjects[Iter] = new PictureBox
                {
                    AutoSize  = true,
                    Size      = new System.Drawing.Size(3 * SizeW, 3 * SizeH),
                    Name      = Convert.ToString(Iter + 1),
                    BackColor = System.Drawing.Color.Transparent,
                    Location  = new System.Drawing.Point(PosX, PosY),
                    Visible   = true,
                    Parent    = this,
                };

                UsableObjects[Iter].MouseClick           += ObjectClicked;
                UsableObjects[Iter].BackgroundImage       = new System.Drawing.Bitmap(CurrObjectImage);
                UsableObjects[Iter].BackgroundImageLayout = ImageLayout.Stretch;
                UsObjScen[Iter] = CurrObject;

                this.Controls.Add(UsableObjects[Iter]);

                // Make object scenarion
                UsSectList[Iter] = new SectionEditon
                {
                    Idx             = Iter, // 0 - Global
                    Section         = 0,
                    SectionNext     = 0,
                    SectionLabel    = 0,
                    SectionLabelOld = 0,

                    SectionString    = "",
                    SectionStringOld = ""
                };
            }

            OldScenario = GameScenarioFile;
        }
Ejemplo n.º 3
0
        private void Label_Helper(bool q, int num, ref SectionEditon CurrSection)
        {
            if (q)
            {
                //this.BackgroundImage = null;
                MessBox_1.Visible = false;

                UniversalPanel.Location = new System.Drawing.Point((this.Width - UniversalPanel.Width) / 2, UniversalPanel.Location.Y);
                UniversalPanel.Width    = 150;

                for (int j = 0; j < num; j++)
                {
                    this.UniversalPanel.Controls.Add(this.label_text[j]);

                    if (label_text[j].Width >= UniversalPanel.Width)
                    {
                        UniversalPanel.Width = label_text[j].Width + 15;
                    }

                    label_text[j].Location = new System.Drawing.Point(10, label_text[j].Location.Y - 15 + j);
                }

                UniversalPanel.Height  = 10 + 15 * num;
                UniversalPanel.Visible = true;

                CurrSection.SectionLabel++;
            }
            else
            {
                for (int j = 0; j < num; j++)
                {
                    label_text[j].Dispose();
                }

                MessBox_1.Visible      = true;
                UniversalPanel.Visible = false;
                NextScene(false, ref CurrSection);
            }
        }
Ejemplo n.º 4
0
        //Прокомментирую, а то уже забыл, что к чему...
        void NextScene(bool load, ref SectionEditon CurrSection)
        {
            // Remove old frame data
            SpriteListPic.Dispose();
            SpriteListPic = new Bitmap(this.Size.Width, this.Size.Height);
            lua.lua.Pop();

            //Флажок для лоадера
            if (!load || bActionState)
            {
                SoundOldName = lua.GetSoundActive();
                CurrSection.Section++;

                //Тут мы определяем секцию, костыльно и не интересно
                CurrSection.SectionString = (CurrSection.SectionLabel == 0) ?
                                            Convert.ToString(CurrSection.Section) : Convert.ToString(CurrSection.Section) + CurrSection.SectionStringOld;

                if (CurrSection.SectionNext != 0 && CurrSection.SectionLabelOld != CurrSection.SectionLabel)
                {
                    CurrSection.SectionStringOld += "_" + Convert.ToString(CurrSection.SectionNext);
                    CurrSection.SectionString     = Convert.ToString(CurrSection.Section) + CurrSection.SectionStringOld;
                    CurrSection.SectionLabelOld   = CurrSection.SectionLabel;
                }
            }

            //Load vars
            string TypeCurrentScene = ifs.GetString(LuaAPI.cfg + GameScenarioFile, CurrSection.SectionString, "type");
            string ScriptFileName   = ifs.GetString(LuaAPI.cfg + GameScenarioFile, CurrSection.SectionString, "name");

            switch (TypeCurrentScene)
            {
            case "SceneDropper":
            {
                CurrSection.SectionString = ifs.GetString(LuaAPI.cfg + GameScenarioFile, CurrSection.SectionString, "id");
                var SplitedSect = CurrSection.SectionString.Split('_');
                CurrSection.Section          = Convert.ToInt32(SplitedSect[0]);
                CurrSection.SectionStringOld = CurrSection.SectionString.Substring(SplitedSect[0].Length, CurrSection.SectionString.Length - SplitedSect[0].Length);
                NextScene(true, ref CurrSection);
                return;
            }

            case "None":
            {
                return;
            }

            case "LuaScript":
            {
                lua.LuaFunc(ScriptFileName, ifs.GetString(LuaAPI.cfg + GameScenarioFile, CurrSection.SectionString, "func"));
                break;
            }

            case "Question":
            {
                lua.LuaFunc(ScriptFileName, ifs.GetString(LuaAPI.cfg + GameScenarioFile, CurrSection.SectionString, "func"));
                LablesCount = lua.GetLabelNum();
                label_text  = new Label[LablesCount];        // Set size
                for (int it = 0; it < LablesCount; it++)
                {
                    label_text[it] = new System.Windows.Forms.Label
                    {
                        AutoSize  = true,
                        Name      = Convert.ToString(it + 1),
                        BackColor = System.Drawing.Color.Transparent,
                        Location  = new System.Drawing.Point(10, 22 + 14 * it),
                        Visible   = true,
                        Text      = lua.GetLabelText(it),
                        Parent    = UniversalPanel
                    };
                    label_text[it].Click += this.Question_Click;
                }
                Label_Helper(true, LablesCount, ref CurrSection);
                return;
            }

            default:
            {
                if (isVisualNovel)
                {
                    MessageBox.Show("Error: Unknown scene type!");
                }
                else
                {
                    bActionState = false;
                }

                return;
            }
            }

            string[] ActorText = lua.GetText().Split(' ');

            // Music
            if (SoundFlagCheck.Checked && (!SoundActive || lua.GetSoundActive() != SoundOldName))
            {
                player.Open(new Uri(LuaAPI.snd + lua.GetSoundActive(), UriKind.Relative));
                player.Play();
                SoundActive = true;
            }

            // Draw ActorName
            SpeakerName.Visible   = true;
            SpeakerName.ForeColor = SetColor(lua.GetNameColor());
            SpeakerName.Text      = lua.GetName();

            // Для отступов строк
            int old_y = 35, StrSize = 0, StrEndl = 0;

            MessBox_1.Image = (Image) new Bitmap(MessBox_1.Width, MessBox_1.Height);

            using (Graphics g = Graphics.FromImage(MessBox_1.Image))
            {
                // Считаем строки
                old_y -= 14;
                for (var i = 0; i <= ActorText.Length; i++)
                {
                    if (StrSize < TextWidth && i != ActorText.Length)
                    {
                        StrSize += ActorText[i].Length;
                        if (i != ActorText.Length - 1)
                        {
                            if (StrSize + ActorText[i + 1].Length >= TextWidth)
                            {
                                StrSize = TextWidth + 12;
                            }
                        }
                    }
                    else
                    {
                        for (int CreatLineIter = StrEndl; CreatLineIter < i; CreatLineIter++)
                        {
                            SpeakerTextString += ActorText[CreatLineIter] + " ";
                        }

                        // Set endl pos
                        StrEndl = i;

                        if (i != ActorText.Length)
                        {
                            StrSize = ActorText[i].Length;
                        }

                        old_y += 14;
                        g.DrawString(SpeakerTextString, new Font(lua.GetTextFont(), 10, FontStyle.Bold), new SolidBrush(SetColor(lua.GetTextColor())), new Point(10, old_y));
                        SpeakerTextString = "";
                    }
                }
            }

            // Drawing img
            this.BackgroundImage = new Bitmap(LuaAPI.images + lua.GetImageText(0));
            int inum = lua.GetImgNum() - 1;

            if (inum > 0)
            {
                for (int it = 1; it <= inum; it++)
                {
                    SpriteBoxesHolder(new Bitmap(LuaAPI.images + lua.GetImageText(it)), lua.GetImageTextPos(it), 0, lua.GetImageScale(it));
                }
            }
        }