Esempio n. 1
0
        public Atom(AppContents contents, int electrons)
        {
            if (contents == null)
            {
                throw new ArgumentNullException(nameof(contents));
            }
            if (electrons < 0 || electrons > 4)
            {
                throw new ArgumentException("Electrons must be a value between 0 and 4");
            }

            _contents = contents;
            _initialElectronsCount = electrons;
            _electronsCount        = electrons;
        }
Esempio n. 2
0
        public AtomsGrid(AppContents contents, GameSession session, int cellSize, int width, int height)
        {
            if (contents == null)
            {
                throw new ArgumentNullException(nameof(contents));
            }
            if (session == null)
            {
                throw new ArgumentNullException(nameof(session));
            }

            _contents = contents;
            _session  = session;
            _tileSize = cellSize;
            _width    = width;
            _height   = height;
            _atoms    = new GridAtom[width, height];
        }
Esempio n. 3
0
        public ConsoleImagePart(string resName, string resNameb, int raw_height, int raw_width, int raw_ypos)
        {
            top                = 0;
            bottom             = Config.FontSize;
            Str                = "";
            ResourceName       = resName ?? "";
            ButtonResourceName = resNameb;
            StringBuilder sb = new StringBuilder();

            sb.Append("<img src='");
            sb.Append(ResourceName);
            if (ButtonResourceName != null)
            {
                sb.Append("' srcb='");
                sb.Append(ButtonResourceName);
            }
            if (raw_height != 0)
            {
                sb.Append("' height='");
                sb.Append(raw_height.ToString());
            }
            if (raw_width != 0)
            {
                sb.Append("' width='");
                sb.Append(raw_height.ToString());
            }
            if (raw_ypos != 0)
            {
                sb.Append("' ypos='");
                sb.Append(raw_height.ToString());
            }
            sb.Append("'>");
            AltText = sb.ToString();
            cImage  = AppContents.GetSprite(ResourceName);
            //if (cImage != null && !cImage.IsCreated)
            //	cImage = null;
            if (cImage == null)
            {
                Str = AltText;
                return;
            }
            int height = 0;

            if (raw_height == 0)
            {
                height = Config.FontSize;
            }
            else
            {
                height = Config.FontSize * raw_height / 100;
            }
            if (raw_width == 0)
            {
                Width     = cImage.Rectangle.Width * height / cImage.Rectangle.Height;
                XsubPixel = ((float)cImage.Rectangle.Width * height) / cImage.Rectangle.Height - Width;
            }
            else
            {
                Width     = Config.FontSize * raw_width / 100;
                XsubPixel = ((float)Config.FontSize * raw_width / 100f) - Width;
            }
            top      = raw_ypos * Config.FontSize / 100;
            destRect = new Rectangle(0, top, Width, height);
            if (destRect.Width < 0)
            {
                destRect.X = -destRect.Width;
                Width      = -destRect.Width;
            }
            if (destRect.Height < 0)
            {
                destRect.Y = destRect.Y - destRect.Height;
                height     = -destRect.Height;
            }
            bottom = top + height;
            //if(top > 0)
            //	top = 0;
            //if(bottom < Config.FontSize)
            //	bottom = Config.FontSize;
            if (ButtonResourceName != null)
            {
                cImageB = AppContents.GetSprite(ButtonResourceName);
                //if (cImageB != null && !cImageB.IsCreated)
                //	cImageB = null;
            }
        }
Esempio n. 4
0
        public ConsoleImagePart(string resName, string resNameb, int raw_height, int raw_width, int raw_ypos)
        {
            top                = 0;
            bottom             = Config.FontSize;
            Str                = "";
            ResourceName       = resName ?? "";
            ButtonResourceName = resNameb;
            StringBuilder sb = new StringBuilder();

            sb.Append("<img src='");
            sb.Append(ResourceName);
            if (ButtonResourceName != null)
            {
                sb.Append("' srcb='");
                sb.Append(ButtonResourceName);
            }
            if (raw_height != 0)
            {
                sb.Append("' height='");
                sb.Append(raw_height.ToString());
            }
            if (raw_width != 0)
            {
                sb.Append("' width='");
                sb.Append(raw_height.ToString());
            }
            if (raw_ypos != 0)
            {
                sb.Append("' ypos='");
                sb.Append(raw_height.ToString());
            }
            sb.Append("'>");
            AltText = sb.ToString();
            cImage  = AppContents.GetSprite(ResourceName);
            //if (cImage != null && !cImage.IsCreated)
            //	cImage = null;
            if (cImage == null)
            {
                Str = AltText;
                return;
            }
            int height = 0;

            if (raw_height == 0)            //HTMLで高さが指定されていない又は0が指定された場合、フォントサイズをそのまま高さ(px単位)として使用する。
            {
                height = Config.FontSize;
            }
            else            //HTMLで高さが指定された場合、フォントサイズの100分率と解釈する。
            {
                height = Config.FontSize * raw_height / 100;
            }
            //幅が指定されていない又は0が指定された場合、元画像の縦横比を維持するように幅(px単位)を設定する。1未満は端数としてXsubpixelに記録。
            //負の値が指定される可能性があるが、最終的なWidthは正の値になるようにあとで調整する。
            if (raw_width == 0)
            {
                Width     = cImage.DestBaseSize.Width * height / cImage.DestBaseSize.Height;
                XsubPixel = ((float)cImage.DestBaseSize.Width * height) / cImage.DestBaseSize.Height - Width;
            }
            else
            {
                Width     = Config.FontSize * raw_width / 100;
                XsubPixel = ((float)Config.FontSize * raw_width / 100f) - Width;
            }
            top      = raw_ypos * Config.FontSize / 100;
            destRect = new Rectangle(0, top, Width, height);
            if (destRect.Width < 0)
            {
                destRect.X = -destRect.Width;
                Width      = -destRect.Width;
            }
            if (destRect.Height < 0)
            {
                destRect.Y = destRect.Y - destRect.Height;
                height     = -destRect.Height;
            }
            bottom = top + height;
            //if(top > 0)
            //	top = 0;
            //if(bottom < Config.FontSize)
            //	bottom = Config.FontSize;
            if (ButtonResourceName != null)
            {
                cImageB = AppContents.GetSprite(ButtonResourceName);
                //if (cImageB != null && !cImageB.IsCreated)
                //	cImageB = null;
            }
        }
Esempio n. 5
0
        public bool Initialize()
        {
            LexicalAnalyzer.UseMacro = false;
            getCurrentState          = new ProcessState(console);
            originalState            = getCurrentState;
            inInitializeing          = true;
            try
            {
                ParserMediator.Initialize(console);
                if (ParserMediator.HasWarning)
                {
                    ParserMediator.FlushWarningList();
                    if (MessageBox.Show("コンフィグファイルに異常があります\nEmueraを終了しますか", "コンフィグエラー", MessageBoxButtons.YesNo)
                        == DialogResult.Yes)
                    {
                        console.PrintSystemLine("コンフィグファイルに異常があり、終了が選択されたため処理を終了しました");
                        return(false);
                    }
                }
                AppContents.LoadContents();

                if (Config.UseKeyMacro && !Program.AnalysisMode)
                {
                    if (File.Exists(Program.ExeDir + "macro.txt"))
                    {
                        if (Config.DisplayReport)
                        {
                            console.PrintSystemLine("macro.txt読み込み中・・・");
                        }
                        KeyMacro.LoadMacroFile(Program.ExeDir + "macro.txt");
                    }
                }
                if (Config.UseReplaceFile && !Program.AnalysisMode)
                {
                    if (File.Exists(Program.CsvDir + "_Replace.csv"))
                    {
                        if (Config.DisplayReport)
                        {
                            console.PrintSystemLine("_Replace.csv読み込み中・・・");
                        }
                        ConfigData.Instance.LoadReplaceFile(Program.CsvDir + "_Replace.csv");
                        if (ParserMediator.HasWarning)
                        {
                            ParserMediator.FlushWarningList();
                            if (MessageBox.Show("_Replace.csvに異常があります\nEmueraを終了しますか", "_Replace.csvエラー",
                                                MessageBoxButtons.YesNo)
                                == DialogResult.Yes)
                            {
                                console.PrintSystemLine("_Replace.csvに異常があり、終了が選択されたため処理を終了しました");
                                return(false);
                            }
                        }
                    }
                }
                Config.SetReplace(ConfigData.Instance);
                //ここでBARを設定すれば、いいことに気づいた予感
                console.setStBar(Config.DrawLineString);

                if (Config.UseRenameFile)
                {
                    if (File.Exists(Program.CsvDir + "_Rename.csv"))
                    {
                        if (Config.DisplayReport || Program.AnalysisMode)
                        {
                            console.PrintSystemLine("_Rename.csv読み込み中・・・");
                        }
                        ParserMediator.LoadEraExRenameFile(Program.CsvDir + "_Rename.csv");
                    }
                    else
                    {
                        console.PrintError("csv\\_Rename.csvが見つかりません");
                    }
                }
                if (!Config.DisplayReport)
                {
                    console.PrintSingleLine(Config.LoadLabel);
                    console.RefreshStrings(true);
                }
                gamebase = new GameBase();
                if (!gamebase.LoadGameBaseCsv(Program.CsvDir + "GAMEBASE.CSV"))
                {
                    console.PrintSystemLine("GAMEBASE.CSVの読み込み中に問題が発生したため処理を終了しました");
                    return(false);
                }
                console.SetWindowTitle(gamebase.ScriptWindowTitle);
                GlobalStatic.GameBaseData = gamebase;

                var constant = new ConstantData(gamebase);
                constant.LoadData(Program.CsvDir, console, Config.DisplayReport);
                GlobalStatic.ConstantData = constant;
                TrainName = constant.GetCsvNameList(VariableCode.TRAINNAME);

                vEvaluator = new VariableEvaluator(gamebase, constant);
                GlobalStatic.VEvaluator = vEvaluator;

                idDic = new IdentifierDictionary(vEvaluator.VariableData);
                GlobalStatic.IdentifierDictionary = idDic;

                StrForm.Initialize();
                VariableParser.Initialize();

                exm = new ExpressionMediator(this, vEvaluator, console);
                GlobalStatic.EMediator = exm;

                labelDic = new LabelDictionary();
                GlobalStatic.LabelDictionary = labelDic;
                var hLoader = new HeaderFileLoader(console, idDic, this);

                LexicalAnalyzer.UseMacro = false;
                if (!hLoader.LoadHeaderFiles(Program.ErbDir, Config.DisplayReport))
                {
                    console.PrintSystemLine("ERHの読み込み中にエラーが発生したため処理を終了しました");
                    return(false);
                }
                LexicalAnalyzer.UseMacro = idDic.UseMacro();

                var loader = new ErbLoader(console, exm, this);
                if (Program.AnalysisMode)
                {
                    noError = loader.loadErbs(Program.AnalysisFiles, labelDic);
                }
                else
                {
                    noError = loader.LoadErbFiles(Program.ErbDir, Config.DisplayReport, labelDic);
                }
                initSystemProcess();
                inInitializeing = false;
            }
            catch (Exception e)
            {
                handleException(e, null, true);
                console.PrintSystemLine("初期化中に致命的なエラーが発生したため処理を終了しました");
                return(false);
            }
            if (labelDic == null)
            {
                return(false);
            }
            getCurrentState.Begin(BeginType.TITLE);
            GC.Collect();
            return(true);
        }
Esempio n. 6
0
        private static void Main(string[] args)
        {
            ExeDir = Sys.ExeDir;
#if DEBUG
            //debugMode = true;
#endif
            CsvDir     = ExeDir + "csv\\";
            ErbDir     = ExeDir + "erb\\";
            DebugDir   = ExeDir + "debug\\";
            DatDir     = ExeDir + "dat\\";
            ContentDir = ExeDir + "resources\\";
            //エラー出力用
            //1815 .exeが東方板のNGワードに引っかかるそうなので除去
            ExeName = Path.GetFileNameWithoutExtension(Sys.ExeName);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            ConfigData.Instance.LoadConfig();
            //二重起動の禁止かつ二重起動
            if (!Config.AllowMultipleInstances && Sys.PrevInstance())
            {
                MessageBox.Show("多重起動を許可する場合、emuera.configを書き換えて下さい", "既に起動しています");
                return;
            }
            if (!Directory.Exists(CsvDir))
            {
                MessageBox.Show("csvフォルダが見つかりません", "フォルダなし");
                return;
            }
            if (!Directory.Exists(ErbDir))
            {
                MessageBox.Show("erbフォルダが見つかりません", "フォルダなし");
                return;
            }
            var argsStart = 0;
            if (args.Length > 0 && args[0].Equals("-DEBUG", StringComparison.CurrentCultureIgnoreCase))
            {
                argsStart = 1; //デバッグモードかつ解析モード時に最初の1っこ(-DEBUG)を飛ばす
                debugMode = true;
            }
            if (debugMode)
            {
                ConfigData.Instance.LoadDebugConfig();
                if (!Directory.Exists(DebugDir))
                {
                    try
                    {
                        Directory.CreateDirectory(DebugDir);
                    }
                    catch
                    {
                        MessageBox.Show("debugフォルダの作成に失敗しました", "フォルダなし");
                        return;
                    }
                }
            }
            if (args.Length > argsStart)
            {
                AnalysisFiles = new List <string>();
                for (var i = argsStart; i < args.Length; i++)
                {
                    if (!File.Exists(args[i]) && !Directory.Exists(args[i]))
                    {
                        MessageBox.Show("与えられたファイル・フォルダは存在しません");
                        return;
                    }
                    if ((File.GetAttributes(args[i]) & FileAttributes.Directory) == FileAttributes.Directory)
                    {
                        var fnames = Config.GetFiles(args[i] + "\\", "*.ERB");
                        for (var j = 0; j < fnames.Count; j++)
                        {
                            AnalysisFiles.Add(fnames[j].Value);
                        }
                    }
                    else
                    {
                        if (Path.GetExtension(args[i]).ToUpper() != ".ERB")
                        {
                            MessageBox.Show("ドロップ可能なファイルはERBファイルのみです");
                            return;
                        }
                        AnalysisFiles.Add(args[i]);
                    }
                }
                AnalysisMode = true;
            }
            MainWindow win = null;
            while (true)
            {
                StartTime = WinmmTimer.TickCount;
                using (win = new MainWindow())
                {
                    Application.Run(win);
                    AppContents.UnloadContents();
                    if (!Reboot)
                    {
                        break;
                    }

                    RebootWinState = win.WindowState;
                    if (win.WindowState == FormWindowState.Normal)
                    {
                        RebootClientY  = win.ClientSize.Height;
                        RebootLocation = win.Location;
                    }
                    else
                    {
                        RebootClientY  = 0;
                        RebootLocation = new Point();
                    }
                }
                //条件次第ではParserMediatorが空でない状態で再起動になる場合がある
                ParserMediator.ClearWarningList();
                ParserMediator.Initialize(null);
                GlobalStatic.Reset();
                //GC.Collect();
                Reboot = false;
                ConfigData.Instance.LoadConfig();
            }
        }