Example #1
0
        protected override Surface CreateSurface()
        {
            if (ParentScreen.Background == null && ParentScreen.UseTiles)
            {
                Surface surf = new Surface(Width, Height);
                surf.Fill(new Rectangle(new Point(0, 0), new Size(Width, Height)),
                          Color.FromArgb(0, 0, 0, 0));
                surf.TransparentColor = Color.Black;                 /* XXX */

                Pcx pal = new Pcx();
                pal.ReadFromStream((Stream)Mpq.GetResource("unit\\cmdbtns\\ticon.pcx"),
                                   -1, -1);

                /* tile the top border */
                TileRow(surf, tileGrp, pal.Palette, TILE_TL, TILE_T, TILE_TR, 0);

                /* tile everything down to the bottom border */
                for (int y = tileGrp.Height - 2; y < surf.Height - tileGrp.Height; y += tileGrp.Height - 2)
                {
                    TileRow(surf, tileGrp, pal.Palette, TILE_L, TILE_C, TILE_R, y);
                }

                /* tile the bottom row */
                TileRow(surf, tileGrp, pal.Palette, TILE_BL, TILE_B, TILE_BR, surf.Height - tileGrp.Height);
                return(surf);
            }
            else
            {
                return(null);
            }
        }
Example #2
0
 public RaceSelectionScreen(Mpq mpq)
     : base(mpq, "glue\\PalCs",
            Game.Instance.PlayingBroodWar ? Builtins.rez_GluExpcmpgnBin : Builtins.rez_GluCmpgnBin)
 {
     background_translucent = 254;
     background_transparent = 0;
 }
Example #3
0
 public GameModeDialog(UIScreen parent, Mpq mpq)
     : base(parent, mpq, "glue\\Palmm", Builtins.rez_GluGameModeBin)
 {
     background_path        = "glue\\Palmm\\retail_ex.pcx";
     background_translucent = 42;
     background_transparent = 0;
 }
Example #4
0
        void Awake()
        {
            try
            {
                Mpq.AddArchive("d2exp.mpq");
                Mpq.AddArchive("d2data.mpq");
                Mpq.AddArchive("d2char.mpq");
                Mpq.AddArchive("d2sfx.mpq", optional: true);
                Mpq.AddArchive("d2music.mpq", optional: true);
                Mpq.AddArchive("d2xMusic.mpq", optional: true);
                Mpq.AddArchive("d2xtalk.mpq", optional: true);
                Mpq.AddArchive("d2speech.mpq", optional: true);
            }
            catch (System.IO.FileNotFoundException e)
            {
                string message = BuildMessage(e.Message);
                ScreenMessage.Show(message);
                return;
            }

            Datasheet.SetLocation(typeof(BodyLoc), "data/global/excel/bodylocs.txt");
            Datasheet.SetLocation(typeof(SoundInfo), "data/global/excel/Sounds.txt");
            EngineData.LoadAll();
            Instantiate(mainMenuPrefab);
        }
Example #5
0
        public ReadyRoomScreen(Mpq mpq,
                               string scenario_prefix,
                               int start_element_index,
                               int cancel_element_index,
                               int skiptutorial_element_index,
                               int replay_element_index,
                               int transmission_element_index,
                               int objectives_element_index,
                               int first_portrait_element_index)
            : base(mpq,
                   String.Format("glue\\Ready{0}", Util.RaceChar[(int)Game.Instance.Race]),
                   String.Format(Builtins.rez_GluRdyBin, Util.RaceCharLower[(int)Game.Instance.Race]))
        {
            background_path = String.Format("glue\\PalR{0}\\Backgnd.pcx", Util.RaceCharLower[(int)Game.Instance.Race]);
            fontpal_path    = String.Format("glue\\PalR{0}\\tFont.pcx", Util.RaceCharLower[(int)Game.Instance.Race]);
            effectpal_path  = String.Format("glue\\PalR{0}\\tEffect.pcx", Util.RaceCharLower[(int)Game.Instance.Race]);
            arrowgrp_path   = String.Format("glue\\PalR{0}\\arrow.grp", Util.RaceCharLower[(int)Game.Instance.Race]);

            this.start_element_index          = start_element_index;
            this.cancel_element_index         = cancel_element_index;
            this.skiptutorial_element_index   = skiptutorial_element_index;
            this.replay_element_index         = replay_element_index;
            this.transmission_element_index   = transmission_element_index;
            this.objectives_element_index     = objectives_element_index;
            this.first_portrait_element_index = first_portrait_element_index;

            this.scenario        = (Chk)mpq.GetResource(scenario_prefix + "\\staredit\\scenario.chk");
            this.scenario_prefix = scenario_prefix;
        }
Example #6
0
        public MovieElement(UIScreen screen, BinElement el, byte[] palette, string resource)
            : base(screen, el, palette)
        {
            Sensitive = false;

            Player = new SmackerPlayer((Stream)Mpq.GetResource(resource), 1);
        }
Example #7
0
 public GameModeDialog(UIScreen parent, Mpq mpq)
     : base(parent, mpq, "glue\\Palmm", Builtins.rez_GluGameModeBin)
 {
     background_path = "glue\\Palmm\\retail_ex.pcx";
     background_translucent = 42;
     background_transparent = 0;
 }
Example #8
0
        protected UIScreen(Mpq mpq)
        {
            this.mpq = mpq;

            Bounds      = new RectangleF(0, 0, 640, 480);
            AnchorPoint = new PointF(0, 0);
        }
Example #9
0
    static public DS1 Load(string filename, bool mpq = true)
    {
        string lowerFilename = filename.ToLower();

        if (cache.ContainsKey(lowerFilename))
        {
            return(cache[lowerFilename]);
        }

        UnityEngine.Profiling.Profiler.BeginSample("DS1.Load");
        try
        {
            var    sw    = System.Diagnostics.Stopwatch.StartNew();
            byte[] bytes = mpq ? Mpq.ReadAllBytes(filename) : File.ReadAllBytes(filename);
            var    ds1   = Load(bytes);
            ds1.filename = filename;
            Debug.Log(Path.GetFileName(filename) + " loaded in " + sw.ElapsedMilliseconds + " ms");
            cache[lowerFilename] = ds1;
            return(ds1);
        }
        finally
        {
            UnityEngine.Profiling.Profiler.EndSample();
        }
    }
Example #10
0
        public MapRenderer(Mpq mpq, Chk chk)
        {
            this.mpq = mpq;
            this.chk = chk;

            pixel_width = (ushort)(chk.Width * 32);
            pixel_height = (ushort)(chk.Height * 32);

            Stream cv5_fs = (Stream)mpq.GetResource (String.Format ("tileset\\{0}.cv5", Util.TilesetNames[(int)chk.Tileset]));
            cv5 = new byte [cv5_fs.Length];
            cv5_fs.Read (cv5, 0, (int)cv5_fs.Length);
            cv5_fs.Close ();

            Stream vx4_fs = (Stream)mpq.GetResource (String.Format ("tileset\\{0}.vx4", Util.TilesetNames[(int)chk.Tileset]));
            vx4 = new byte [vx4_fs.Length];
            vx4_fs.Read (vx4, 0, (int)vx4_fs.Length);
            vx4_fs.Close ();

            Stream vr4_fs = (Stream)mpq.GetResource (String.Format ("tileset\\{0}.vr4", Util.TilesetNames[(int)chk.Tileset]));
            vr4 = new byte [vr4_fs.Length];
            vr4_fs.Read (vr4, 0, (int)vr4_fs.Length);
            vr4_fs.Close ();

            Stream wpe_fs = (Stream)mpq.GetResource (String.Format ("tileset\\{0}.wpe", Util.TilesetNames[(int)chk.Tileset]));
            wpe = new byte [wpe_fs.Length];
            wpe_fs.Read (wpe, 0, (int)wpe_fs.Length);
            wpe_fs.Close ();
        }
Example #11
0
    static public DC6 Load(string filename, bool mpq = true, int textureSize = -1, bool loadAllDirections = false)
    {
        UnityEngine.Profiling.Profiler.BeginSample("DC6.DecodeDirection");
        try
        {
            Palette.LoadPalette(0);
            var bytes = mpq ? Mpq.ReadAllBytes(filename) : File.ReadAllBytes(filename);

            using (var stream = new MemoryStream(bytes))
                using (var reader = new BinaryReader(stream))
                {
                    int version1 = reader.ReadInt32();
                    var version2 = reader.ReadInt32();
                    var version3 = reader.ReadInt32();
                    if (version1 != 6 || version2 != 1 || version3 != 0)
                    {
                        Debug.LogWarning("Unknown dc6 version " + version1 + " " + version2 + " " + version3);
                        return(null);
                    }

                    DC6 dc6 = Load(stream, reader, bytes, textureSize, loadAllDirections);
                    return(dc6);
                }
        }
        finally
        {
            UnityEngine.Profiling.Profiler.EndSample();
        }
    }
Example #12
0
		public ReadyRoomScreen (Mpq mpq,
					string scenario_prefix,
					int start_element_index,
					int cancel_element_index,
					int skiptutorial_element_index,
					int replay_element_index,
					int transmission_element_index,
					int objectives_element_index,
					int first_portrait_element_index)
			: base (mpq,
				String.Format ("glue\\Ready{0}", Util.RaceChar[(int)Game.Instance.Race]),
				String.Format (Builtins.rez_GluRdyBin, Util.RaceCharLower[(int)Game.Instance.Race]))
		{
			background_path = String.Format ("glue\\PalR{0}\\Backgnd.pcx", Util.RaceCharLower[(int)Game.Instance.Race]);
			fontpal_path = String.Format ("glue\\PalR{0}\\tFont.pcx", Util.RaceCharLower[(int)Game.Instance.Race]);
			effectpal_path = String.Format ("glue\\PalR{0}\\tEffect.pcx", Util.RaceCharLower[(int)Game.Instance.Race]);
			arrowgrp_path = String.Format ("glue\\PalR{0}\\arrow.grp", Util.RaceCharLower[(int)Game.Instance.Race]);

			this.start_element_index = start_element_index;
			this.cancel_element_index = cancel_element_index;
			this.skiptutorial_element_index = skiptutorial_element_index;
			this.replay_element_index = replay_element_index;
			this.transmission_element_index = transmission_element_index;
			this.objectives_element_index = objectives_element_index;
			this.first_portrait_element_index = first_portrait_element_index;

			this.scenario = (Chk)mpq.GetResource (scenario_prefix + "\\staredit\\scenario.chk");
			this.scenario_prefix = scenario_prefix;
		}
Example #13
0
        public Sprite(Mpq mpq, int sprite_entry, byte[] palette, int x, int y)
        {
            this.mpq     = mpq;
            this.palette = palette;

            images_entry = GlobalResources.Instance.SpritesDat.ImagesDatEntries [sprite_entry];
            //			Console.WriteLine ("image_dat_entry == {0}", images_entry);

            uint grp_index = GlobalResources.Instance.ImagesDat.GrpIndexes [images_entry];

            //			Console.WriteLine ("grp_index = {0}", grp_index);
            grp_path = GlobalResources.Instance.ImagesTbl[(int)grp_index - 1];
            //			Console.WriteLine ("grp_path = {0}", grp_path);

            grp = (Grp)mpq.GetResource("unit\\" + grp_path);

            iscript_entry       = GlobalResources.Instance.ImagesDat.IScriptIndexes [images_entry];
            script_entry_offset = GlobalResources.Instance.IScriptBin.GetScriptEntryOffset(iscript_entry);

            Console.WriteLine("new sprite: unit\\{0} @ {1}x{2} (image {3}, iscript id {4}, script_entry_offset {5:X})",
                              grp_path, x, y, images_entry, iscript_entry, script_entry_offset);

            this.buf = GlobalResources.Instance.IScriptBin.Contents;

            /* make sure the offset points to "SCPE" */
            if (Util.ReadDWord(buf, script_entry_offset) != 0x45504353)
            {
                Console.WriteLine("invalid script_entry_offset");
            }

            SetPosition(x, y);
        }
Example #14
0
        public Sprite(Sprite parentSprite, ushort images_entry, byte[] palette)
        {
            this.parent_sprite = parentSprite;
            this.mpq           = parentSprite.mpq;
            this.palette       = palette;
            this.images_entry  = images_entry;

            uint grp_index = GlobalResources.Instance.ImagesDat.GrpIndexes [images_entry];

            grp_path = GlobalResources.Instance.ImagesTbl[(int)grp_index - 1];

            grp = (Grp)mpq.GetResource("unit\\" + grp_path);

            this.buf      = GlobalResources.Instance.IScriptBin.Contents;
            iscript_entry = GlobalResources.Instance.ImagesDat.IScriptIndexes [images_entry];

            script_entry_offset = GlobalResources.Instance.IScriptBin.GetScriptEntryOffset(iscript_entry);

            Console.WriteLine("new dependent sprite: unit\\{0} (image {1}, iscript id {2}, script_entry_offset {3:X})",
                              grp_path, images_entry, iscript_entry, script_entry_offset);

            /* make sure the offset points to "SCEP" */
            if (Util.ReadDWord(buf, script_entry_offset) != 0x45504353)
            {
                Console.WriteLine("invalid script_entry_offset");
            }

            int x, y;

            parentSprite.GetPosition(out x, out y);
            SetPosition(x, y);
        }
Example #15
0
        private void LoadAll(LoadProgress progress)
        {
            var           sw      = Stopwatch.StartNew();
            List <Action> actions = new List <Action>();

            foreach (var mpqLocation in paths.mpq)
            {
                actions.Add(() => Mpq.AddArchive(mpqLocation.filename, mpqLocation.optional));
            }
            actions.Add(() => AnimData.Load(paths.animData));
            actions.Add(Translation.Load);
            actions.Add(SoundInfo.Load);
            actions.Add(SoundEnvironment.Load);
            actions.Add(ObjectInfo.Load);
            actions.Add(BodyLoc.Load);
            actions.Add(ExpTable.Load);
            actions.Add(LevelType.Load);
            actions.Add(LevelWarpInfo.Load);
            actions.Add(LevelPreset.Load);
            actions.Add(LevelMazeInfo.Load);
            actions.Add(LevelInfo.Load);
            actions.Add(OverlayInfo.Load);
            actions.Add(MissileInfo.Load);
            actions.Add(ItemStat.Load);
            actions.Add(ItemRatio.Load);
            actions.Add(ItemType.Load);
            actions.Add(ItemPropertyInfo.Load);
            actions.Add(ItemSet.Load);
            actions.Add(UniqueItem.Load);
            actions.Add(SetItem.Load);
            actions.Add(TreasureClass.Load);
            actions.Add(MagicAffix.Load);
            actions.Add(CharStatsInfo.Load);
            actions.Add(MonLvl.Load);
            actions.Add(MonPreset.Load);
            actions.Add(MonSound.Load);
            actions.Add(MonStatsExtended.Load);
            actions.Add(MonStat.Load);
            actions.Add(SuperUnique.Load);
            actions.Add(SkillDescription.Load);
            actions.Add(SkillInfo.Load);
            actions.Add(SpawnPreset.Load);
            actions.Add(StateInfo.Load);
            progress.totalCount = actions.Count;
            try
            {
                foreach (Action action in actions)
                {
                    action();
                    progress.doneCount++;
                }
            }
            catch (Exception e)
            {
                progress.exception = e;
            }
            progress.finished = true;
            Debug.Log("DataLoader finished in " + sw.ElapsedMilliseconds + " ms");
        }
Example #16
0
        static void Main(string[] args)
        {
            Mpq.ExtractFile("DBFilesClient\\Item-sparse.db2", "Item-sparse.db2", OpenFile.PATCHED_FILE);
            Mpq.ExtractFile("DBFilesClient\\ItemCurrencyCost.db2", "ItemCurrencyCost.db2", OpenFile.PATCHED_FILE);

            Mpq.Close();

            Console.ReadKey();
        }
Example #17
0
    static public DCC Load(string filename, bool loadAllDirections = false, bool mpq = true)
    {
        UnityEngine.Profiling.Profiler.BeginSample("DCC.Load");
        var bytes = mpq ? Mpq.ReadAllBytes(filename) : File.ReadAllBytes(filename);
        DCC dcc   = Load(filename, bytes, loadAllDirections);

        UnityEngine.Profiling.Profiler.EndSample();
        return(dcc);
    }
Example #18
0
    public DumpIScript(Mpq mpq)
    {
        new GlobalResources(mpq, null).LoadSingleThreaded();

        bin = GlobalResources.Instance.IScriptBin;
        buf = bin.Contents;

        blocks = new List <Block>();
        labels = new Dictionary <ushort, string>();
    }
Example #19
0
        public static Stream GetFile(ulong hash)
        {
            Stream file = Mpq.GetFile(hash);

            if (file == null)
            {
                throw new FileNotFoundException("Unable to find " + hash);
            }
            return(file);
        }
Example #20
0
        public static Stream GetFile(uint fileId)
        {
            Stream file = Mpq.GetFile(fileId);

            if (file == null)
            {
                throw new FileNotFoundException("Unable to find " + fileId);
            }
            return(file);
        }
Example #21
0
        public static Stream GetFile(string path)
        {
            Stream file = Mpq.GetFile(path);

            if (file == null)
            {
                throw new FileNotFoundException("Unable to find " + path);
            }
            return(file);
        }
Example #22
0
 public GameScreen(Mpq mpq,
                   string prefix,
                   Chk scenario) : base(mpq)
 {
     this.effectpal_path = "game\\tblink.pcx";
     this.arrowgrp_path  = "cursor\\arrow.grp";
     this.fontpal_path   = "game\\tfontgam.pcx";
     //this.scenario_mpq = scenario_mpq;
     this.scenario = scenario;
     ScrollCursors = new CursorAnimator[8];
 }
Example #23
0
        public static void PlayMusic(Mpq mpq, string resourcePath, int numLoops)
        {
            Stream stream = (Stream)mpq.GetResource(resourcePath);

            if (stream == null)
            {
                return;
            }
            Sound s = GuiUtil.SoundFromStream(stream);

            s.Play(true);
        }
Example #24
0
        public static void PlaySound(Mpq mpq, string resourcePath)
        {
            Stream stream = (Stream)mpq.GetResource(resourcePath);

            if (stream == null)
            {
                return;
            }
            NSSound s = GuiUtil.SoundFromStream(stream);

            s.Play();
        }
Example #25
0
        public Sprite CreateSprite(Mpq mpq, byte[] palette)
        {
            if (sprite != null)
            {
                throw new Exception();
            }

            sprite = SpriteManager.CreateSprite(mpq, SpriteId, palette, x, y);

            sprite.RunScript(AnimationType.Init);

            return(sprite);
        }
Example #26
0
        protected UIDialog(UIScreen parent, Mpq mpq, string prefix, string binFile)
            : base(mpq, prefix, binFile)
        {
            this.parent = parent;
            background_translucent = 254;
            background_transparent = 0;

            dimScreen = true;

            dimScreenSurface = new Surface (Painter.SCREEN_RES_X, Painter.SCREEN_RES_Y);
            dimScreenSurface.Alpha = 100;
            dimScreenSurface.AlphaBlending = true;
        }
Example #27
0
 public ZergReadyRoomScreen(Mpq mpq,
                            string scenario_prefix)
     : base(mpq,
            scenario_prefix,
            START_ELEMENT_INDEX,
            CANCEL_ELEMENT_INDEX,
            SKIPTUTORIAL_ELEMENT_INDEX,
            REPLAY_ELEMENT_INDEX,
            TRANSMISSION_ELEMENT_INDEX,
            OBJECTIVES_ELEMENT_INDEX,
            FIRST_PORTRAIT_ELEMENT_INDEX)
 {
 }
Example #28
0
 public GameScreen(Mpq mpq,
                   Mpq scenario_mpq,
                   Chk scenario,
                   Got template) : base(mpq)
 {
     effectpal_path = "game\\tblink.pcx";
     arrowgrp_path  = "cursor\\arrow.grp";
     fontpal_path   = "game\\tfontgam.pcx";
     //this.scenario_mpq = scenario_mpq;
     this.scenario = scenario;
     this.template = template;
     ScrollCursors = new CursorAnimator[8];
 }
Example #29
0
		public GlobalResources (Mpq stardatMpq, Mpq broodatMpq)
		{
			if (instance != null)
				throw new Exception ("There can only be one GlobalResources");

			this.stardatMpq = stardatMpq;
			this.broodatMpq = broodatMpq;

			starcraftResources = new Resources();
			broodwarResources = new Resources();

			instance = this;
		}
Example #30
0
        protected UIDialog(UIScreen parent, Mpq mpq, string prefix, string binFile)
            : base(mpq, prefix, binFile)
        {
            this.parent            = parent;
            background_translucent = 254;
            background_transparent = 0;

            dimScreen = true;

            dimScreenSurface               = new Surface(Painter.SCREEN_RES_X, Painter.SCREEN_RES_Y);
            dimScreenSurface.Alpha         = 100;
            dimScreenSurface.AlphaBlending = true;
        }
Example #31
0
        void AddMovieElements(int elementIndex, int campaign, int off_x, int off_y)
        {
            MovieElement normalElement, onElement, diskElement;

            if (diskPlayer == null)
            {
                diskPlayer = new SmackerPlayer((Stream)Mpq.GetResource(Game.Instance.PlayingBroodWar ? "glue\\Expcampaign\\disk.smk" : "glue\\campaign\\disk.smk"), 1);
            }

            diskElement = new MovieElement(this,
                                           Elements[elementIndex].BinElement,
                                           Elements[elementIndex].Palette,
                                           diskPlayer);

            diskElement.X1 = (ushort)(Elements[elementIndex].X1 + ((Elements[elementIndex].Width - diskElement.MovieSize.Width) / 2));
            diskElement.Y1 = (ushort)(((ButtonElement)Elements[elementIndex]).TextPosition.Y - diskElement.MovieSize.Height);

            normalElement = new MovieElement(this,
                                             Elements[elementIndex].BinElement,
                                             Elements[elementIndex].Palette,
                                             (Game.Instance.PlayingBroodWar ? BroodwarCampaigns : StarcraftCampaigns)[campaign].normalMovie);

            normalElement.X1 = (ushort)(Elements[elementIndex].X1 + ((Elements[elementIndex].Width - normalElement.MovieSize.Width) / 2) + off_x);
            normalElement.Y1 = (ushort)(((ButtonElement)Elements[elementIndex]).TextPosition.Y - normalElement.MovieSize.Height + off_y);

            onElement = new MovieElement(this,
                                         Elements[elementIndex].BinElement,
                                         Elements[elementIndex].Palette,
                                         (Game.Instance.PlayingBroodWar ? BroodwarCampaigns : StarcraftCampaigns)[campaign].onMovie);

            onElement.X1 = (ushort)(Elements[elementIndex].X1 + ((Elements[elementIndex].Width - onElement.MovieSize.Width) / 2));
            onElement.Y1 = (ushort)(((ButtonElement)Elements[elementIndex]).TextPosition.Y - onElement.MovieSize.Height);

            smkElements.Add(diskElement);
            smkElements.Add(normalElement);
            smkElements.Add(onElement);

            onElement.Visible = false;
            normalElement.Dim(100);

            Elements[elementIndex].MouseEnterEvent +=
                delegate() {
                normalElement.Dim(0);
                onElement.Visible = true;
            };
            Elements[elementIndex].MouseLeaveEvent +=
                delegate() {
                normalElement.Dim(100);
                onElement.Visible = false;
            };
        }
Example #32
0
		public static Fnt[] GetFonts (Mpq mpq) {
			if (fonts == null) {
				string[] font_list;
				font_list = BroodwarFonts;

				fonts = new Fnt[font_list.Length];

				for (int i = 0; i < fonts.Length; i ++) {
					fonts[i] = (Fnt)mpq.GetResource (font_list[i]);
					Console.WriteLine ("fonts[{0}] = {1}", i, fonts[i] == null ? "null" : "not null");
				}
			}
			return fonts;
		}
Example #33
0
        protected UIDialog(UIScreen parent, Mpq mpq, string prefix, string binFile)
            : base(mpq, prefix, binFile)
        {
            this.parent            = parent;
            background_translucent = 254;
            background_transparent = 0;

            dimScreen = true;

            dimLayer                 = CALayer.Create();
            dimLayer.Bounds          = parent.Bounds;
            dimLayer.AnchorPoint     = new PointF(0, 0);
            dimLayer.BackgroundColor = new CGColor(0, 0, 0, .7f);
        }
Example #34
0
        public GlobalResources(Mpq stardatMpq, Mpq broodatMpq)
        {
            if (instance != null)
            {
                throw new Exception("There can only be one GlobalResources");
            }

            this.stardatMpq = stardatMpq;
            this.broodatMpq = broodatMpq;

            starcraftResources = new Resources();
            broodwarResources  = new Resources();

            instance = this;
        }
Example #35
0
        void FileListSelectionChanged(int selectedIndex)
        {
            string map_path = Path.Combine(curdir, file_listbox.SelectedItem);

            if (selectedScenario != null)
            {
                selectedScenario.Dispose();
            }

            if (selectedIndex < directories.Length)
            {
                selectedScenario = null;
                selectedChk      = null;
            }
            else
            {
                selectedScenario = new MpqArchive(map_path);

                selectedChk = (Chk)selectedScenario.GetResource("staredit\\scenario.chk");
            }

            Elements[MAPTITLE_ELEMENT_INDEX].Text       = selectedChk == null ? "" : selectedChk.Name;
            Elements[MAPDESCRIPTION_ELEMENT_INDEX].Text = selectedChk == null ? "" : selectedChk.Description;

            string mapSizeString = GlobalResources.Instance.GluAllTbl.Strings[MAPSIZE_FORMAT_INDEX];
            //			string mapDimString = GlobalResources.Instance.GluAllTbl.Strings[MAPDIM_FORMAT_INDEX];
            string tileSetString = GlobalResources.Instance.GluAllTbl.Strings[TILESET_FORMAT_INDEX];

            mapSizeString = mapSizeString.Replace("%c", " ");              /* should probably be a tab.. */
            mapSizeString = mapSizeString.Replace("%s",
                                                  (selectedChk == null
                                                                ? ""
                                                                : String.Format("{0}x{1}",
                                                                                selectedChk.Width,
                                                                                selectedChk.Height)));

            tileSetString = tileSetString.Replace("%c", " ");              /* should probably be a tab.. */
            tileSetString = tileSetString.Replace("%s",
                                                  (selectedChk == null
                                                                ? ""
                                                                : String.Format("{0}",
                                                                                selectedChk.Tileset)));

            Elements[MAPSIZE_ELEMENT_INDEX].Text    = mapSizeString;
            Elements[MAPTILESET_ELEMENT_INDEX].Text = tileSetString;

            UpdatePlayersDisplay();
        }
Example #36
0
		protected UIDialog dialog; /* the currently popped up dialog */

		protected UIScreen (Mpq mpq, string prefix, string binFile)
		{
			this.mpq = mpq;
			this.prefix = prefix; 
			this.binFile = binFile;

			if (prefix != null) {
				background_path = prefix + "\\Backgnd.pcx";
				fontpal_path = prefix + "\\tFont.pcx";
				effectpal_path = prefix + "\\tEffect.pcx";
				arrowgrp_path = prefix + "\\arrow.grp";
			}

			background_transparent = 0;
			background_translucent = 254;
		}
Example #37
0
		public VideoDialog (UIScreen parent, Mpq mpq)
			: base (parent, mpq, "glue\\Palmm", Builtins.rez_VideoBin)
		{
			background_path = null;
		}
Example #38
0
 public MapRenderer(Mpq mpq, Chk chk, int width, int height)
     : this(mpq, chk)
 {
     this.width = width;
     this.height = height;
 }
Example #39
0
        public byte[] RenderToBitmap(Mpq mpq, Chk chk)
        {
            ushort[,] mapTiles = chk.MapTiles;

            byte[] image = new byte[pixel_width * pixel_height * 4];

            for (int map_y = 0; map_y < chk.Height; map_y++) {
                for (int map_x = 0; map_x < chk.Width; map_x ++) {
                    int mapTile = mapTiles[map_x,map_y];

                    //					bool odd = (mapTile & 0x10) == 0x10;

                    int tile_group = mapTile >> 4; /* the tile's group in the cv5 file */
                    int tile_number = mapTile & 0x0F;    /* the megatile within the tile group */

                    int megatile_id = Util.ReadWord (cv5, (tile_group * 26 + 10 + tile_number) * 2);

                    int minitile_x, minitile_y;

                    for (minitile_y = 0; minitile_y < 4; minitile_y ++) {
                        for (minitile_x = 0; minitile_x < 4; minitile_x ++) {
                            ushort minitile_id = Util.ReadWord (vx4, megatile_id * 32 + minitile_y * 8 + minitile_x * 2);
                            bool flipped = (minitile_id & 0x01) == 0x01;
                            minitile_id >>= 1;

                            int pixel_x, pixel_y;
                            if (flipped) {
                                for (pixel_y = 0; pixel_y < 8; pixel_y++)
                                    for (pixel_x = 0; pixel_x < 8; pixel_x ++) {
                                        int x = map_x * 32 + (minitile_x + 1) * 8 - pixel_x - 1;
                                        int y = (map_y * 32 + minitile_y * 8) * pixel_width + pixel_y * pixel_width;

                                        byte palette_entry = vr4[minitile_id * 64 + pixel_y * 8 + pixel_x];

                                        image[0 + 4 * (x + y)] = (byte)(255 - wpe[palette_entry * 4 + 3]);
                                        image[1 + 4 * (x + y)] = wpe[palette_entry * 4 + 2];
                                        image[2 + 4 * (x + y)] = wpe[palette_entry * 4 + 1];
                                        image[3 + 4 * (x + y)] = wpe[palette_entry * 4 + 0];
                                    }
                            }
                            else {
                                for (pixel_y = 0; pixel_y < 8; pixel_y++) {
                                    for (pixel_x = 0; pixel_x < 8; pixel_x ++) {
                                        int x = map_x * 32 + minitile_x * 8 + pixel_x;
                                        int y = (map_y * 32 + minitile_y * 8) * pixel_width + pixel_y * pixel_width;

                                        byte palette_entry = vr4[minitile_id * 64 + pixel_y * 8 + pixel_x];

                                        image[0 + 4 * (x + y)] = (byte)(255 - wpe[palette_entry * 4 + 3]);
                                        image[1 + 4 * (x + y)] = wpe[palette_entry * 4 + 2];
                                        image[2 + 4 * (x + y)] = wpe[palette_entry * 4 + 1];
                                        image[3 + 4 * (x + y)] = wpe[palette_entry * 4 + 0];
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return image;
        }
Example #40
0
 public EstablishingShot(string markup_resource, string scenario_prefix, Mpq mpq)
     : base(mpq)
 {
     this.markup_resource = markup_resource;
     this.scenario_prefix = scenario_prefix;
 }
Example #41
0
		public Sprite (Sprite parentSprite, ushort images_entry, byte[] palette)
		{
			this.parent_sprite = parentSprite;
			this.mpq = parentSprite.mpq;
			this.palette = palette;
			this.images_entry = images_entry;

			uint grp_index = GlobalResources.Instance.ImagesDat.GrpIndexes [images_entry];

			grp_path = GlobalResources.Instance.ImagesTbl[(int)grp_index-1];

			grp = (Grp)mpq.GetResource ("unit\\" + grp_path);

			this.buf = GlobalResources.Instance.IScriptBin.Contents;
			iscript_entry = GlobalResources.Instance.ImagesDat.IScriptIndexes [images_entry];

			script_entry_offset = GlobalResources.Instance.IScriptBin.GetScriptEntryOffset (iscript_entry);

			Console.WriteLine ("new dependent sprite: unit\\{0} (image {1}, iscript id {2}, script_entry_offset {3:X})",
					   grp_path, images_entry, iscript_entry, script_entry_offset);

			/* make sure the offset points to "SCEP" */
			if (Util.ReadDWord (buf, script_entry_offset) != 0x45504353)
				Console.WriteLine ("invalid script_entry_offset");

			int x, y;
			parentSprite.GetPosition (out x, out y);
			SetPosition (x,y);
		}
Example #42
0
 public RestartConfirmationDialog(UIScreen parent, Mpq mpq)
     : base(parent, mpq, "glue\\Palmm", Builtins.rez_RestartBin)
 {
     background_path = null;
 }
Example #43
0
 public KeystrokeDialog(UIScreen parent, Mpq mpq)
     : base(parent, mpq, "glue\\Palmm", Builtins.rez_HelpBin)
 {
     background_path = null;
 }
Example #44
0
		public Game (string starcraftDir, string scCDDir, string bwCDDir)
		{
			instance = this;

			starcraftDir = starcraftDir.Replace ('\\', Path.DirectorySeparatorChar)
						   .Replace ('/', Path.DirectorySeparatorChar);

			scCDDir = scCDDir.Replace ('\\', Path.DirectorySeparatorChar)
					 .Replace ('/', Path.DirectorySeparatorChar);

			bwCDDir = bwCDDir.Replace ('\\', Path.DirectorySeparatorChar)
					 .Replace ('/', Path.DirectorySeparatorChar);

			screens = new UIScreen[(int)UIScreenType.ScreenCount];

			installedMpq = new MpqContainer ();
			playingMpq = new MpqContainer ();

			Mpq scMpq = null, bwMpq = null;

			if (starcraftDir != null) {
				foreach (string path in Directory.GetFileSystemEntries (starcraftDir)) {
					if (Path.GetFileName (path).ToLower() == "broodat.mpq" || Path.GetFileName (path).Equals ("Brood War Data")) {
						if (broodatMpq != null)
							throw new Exception ("You have multiple broodat.mpq files in your starcraft directory.");
						try {
							bwMpq = GetMpq (path);
							Console.WriteLine ("found BrooDat.mpq");
						}
						catch (Exception e) {
							throw new Exception (String.Format ("Could not read mpq archive {0}",
											    path),
									     e);
						}
					}
					else if (Path.GetFileName (path).ToLower() == "stardat.mpq" || Path.GetFileName (path).Equals ("Starcraft Data")) {
						if (stardatMpq != null)
							throw new Exception ("You have multiple stardat.mpq files in your starcraft directory.");
						try {
							scMpq = GetMpq (path);
							Console.WriteLine ("found StarDat.mpq");
						}
						catch (Exception e) {
							throw new Exception (String.Format ("could not read mpq archive {0}",
											    path),
									     e);
						}
					}
					else if (Path.GetFileName (path).ToLower() == "patch_rt.mpq" || Path.GetFileName (path).Equals ("Starcraft Mac Patch")) {
						if (patchRtMpq != null)
							throw new Exception ("You have multiple patch_rt.mpq files in your starcraft directory.");
						try {
							patchRtMpq = GetMpq (path);
							Console.WriteLine ("found patch_rt.mpq");
						}
						catch (Exception e) {
							throw new Exception (String.Format ("could not read mpq archive {0}",
											    path),
									     e);
						}
					}
					else if (Path.GetFileName (path).ToLower() == "starcraft.mpq") {
						try {
							scInstallExe = GetMpq (path);
							Console.WriteLine ("found starcraft.mpq");
						}
						catch (Exception e) {
							throw new Exception (String.Format ("could not read mpq archive {0}",
											    path),
									     e);
						}
					}
					else if (Path.GetFileName (path).ToLower() == "broodwar.mpq") {
						try {
							bwInstallExe = GetMpq (path);
							Console.WriteLine ("found broodwar.mpq");
						}
						catch (Exception e) {
							throw new Exception (String.Format ("could not read mpq archive {0}",
											    path),
									     e);
						}
					}
				}
			}

			if (scMpq == null) {
				throw new Exception ("unable to locate stardat.mpq, please check your StarcraftDirectory configuration setting");
			}

			if (!string.IsNullOrEmpty (scCDDir)) {
				foreach (string path in Directory.GetFileSystemEntries (scCDDir)) {
					if (Path.GetFileName (path).ToLower() == "install.exe" || Path.GetFileName (path).Equals ("Starcraft Archive")) {
						try {
							scInstallExe = GetMpq (path);
							Console.WriteLine ("found SC install.exe");
						}
						catch (Exception e) {
							throw new Exception (String.Format ("could not read mpq archive {0}",
											    path),
									     e);
						}
					}
				}
			}

			if (!string.IsNullOrEmpty (bwCDDir)) {
				foreach (string path in Directory.GetFileSystemEntries (bwCDDir)) {
					if (Path.GetFileName (path).ToLower() == "install.exe" || Path.GetFileName (path).Equals ("Brood War Archive")) {
						try {
							bwInstallExe = GetMpq (path);
							Console.WriteLine ("found BW install.exe");
						}
						catch (Exception e) {
							throw new Exception (String.Format ("could not read mpq archive {0}",
											    path),
									     e);
						}
					}
				}
			}

			if (bwInstallExe == null)
				throw new Exception ("unable to locate broodwar cd's install.exe, please check your BroodwarCDDirectory configuration setting");

			if (bwMpq != null) {
				if (patchRtMpq != null) {
					broodatMpq = new MpqContainer ();
					((MpqContainer)broodatMpq).Add (patchRtMpq);
					((MpqContainer)broodatMpq).Add (bwMpq);
				}
				else
					broodatMpq = bwMpq;
			}

			if (scMpq != null) {
				if (patchRtMpq != null) {
					stardatMpq = new MpqContainer ();
					((MpqContainer)stardatMpq).Add (patchRtMpq);
					((MpqContainer)stardatMpq).Add (scMpq);
				}
				else
					stardatMpq = bwMpq;
			}

			if (broodatMpq != null)
				installedMpq.Add (broodatMpq);
			if (bwInstallExe != null)
				installedMpq.Add (bwInstallExe);
			if (stardatMpq != null)
				installedMpq.Add (stardatMpq);
			if (scInstallExe != null)
				installedMpq.Add (scInstallExe);
			
			PlayingBroodWar = isBroodWar = (broodatMpq != null);
			
			this.rootDir = starcraftDir;
		}
Example #45
0
 public PlayCustomScreen(Mpq mpq)
     : base(mpq, "glue\\PalNl", Builtins.rez_GluCustmBin)
 {
 }
Example #46
0
        void FileListSelectionChanged(int selectedIndex)
        {
            string map_path = Path.Combine (curdir, file_listbox.SelectedItem);

            if (selectedScenario !=null)
                selectedScenario.Dispose ();

            if (selectedIndex < directories.Length) {
                selectedScenario = null;
                selectedChk = null;
            }
            else {
                selectedScenario = new MpqArchive (map_path);

                selectedChk = (Chk)selectedScenario.GetResource ("staredit\\scenario.chk");
            }

            Elements[MAPTITLE_ELEMENT_INDEX].Text = selectedChk == null ? "" : selectedChk.Name;
            Elements[MAPDESCRIPTION_ELEMENT_INDEX].Text = selectedChk == null ? "" : selectedChk.Description;

            string mapSizeString = GlobalResources.Instance.GluAllTbl.Strings[MAPSIZE_FORMAT_INDEX];
            //			string mapDimString = GlobalResources.Instance.GluAllTbl.Strings[MAPDIM_FORMAT_INDEX];
            string tileSetString = GlobalResources.Instance.GluAllTbl.Strings[TILESET_FORMAT_INDEX];

            mapSizeString = mapSizeString.Replace ("%c", " "); /* should probably be a tab.. */
            mapSizeString = mapSizeString.Replace ("%s",
                                   (selectedChk == null
                                ? ""
                                : String.Format ("{0}x{1}",
                                         selectedChk.Width,
                                         selectedChk.Height)));

            tileSetString = tileSetString.Replace ("%c", " "); /* should probably be a tab.. */
            tileSetString = tileSetString.Replace ("%s",
                                   (selectedChk == null
                                ? ""
                                : String.Format ("{0}",
                                         selectedChk.Tileset)));

            Elements[MAPSIZE_ELEMENT_INDEX].Text = mapSizeString;
            Elements[MAPTILESET_ELEMENT_INDEX].Text = tileSetString;

            UpdatePlayersDisplay ();
        }
		public RaceSelectionScreen (Mpq mpq) 
			: base (mpq, "glue\\PalCs",
				Game.Instance.PlayingBroodWar ? Builtins.rez_GluExpcmpgnBin : Builtins.rez_GluCmpgnBin)
		{
		}
Example #48
0
 public GameMenuDialog(UIScreen parent, Mpq mpq)
     : base(parent, mpq, "glue\\Palmm", Builtins.rez_GameMenuBin)
 {
     background_path = null;
 }
Example #49
0
		public OptionsDialog (UIScreen parent, Mpq mpq)
			: base (parent, mpq, "glue\\Palmm", Builtins.rez_OptionsBin)
		{
			background_path = null;
		}
Example #50
0
 public ObjectivesDialog(UIScreen parent, Mpq mpq)
     : base(parent, mpq, "glue\\Palmm", Builtins.rez_ObjctDlgBin)
 {
     background_path = null;
 }
Example #51
0
        public static ReadyRoomScreen Create(Mpq mpq,
						      string scenario_prefix)
        {
            switch (Game.Instance.Race) {
            case Race.Terran:
                return new TerranReadyRoomScreen (mpq, scenario_prefix);
            case Race.Protoss:
                return new ProtossReadyRoomScreen (mpq, scenario_prefix);
            case Race.Zerg:
                return new ZergReadyRoomScreen (mpq, scenario_prefix);
            default:
                return null;
            }
        }
Example #52
0
 public EndMissionDialog(UIScreen parent, Mpq mpq)
     : base(parent, mpq, "glue\\Palmm", Builtins.rez_AbrtMenuBin)
 {
     background_path = null;
 }
Example #53
0
        public ZergReadyRoomScreen(Mpq mpq,
					      string scenario_prefix)
            : base(mpq,
				scenario_prefix,
				START_ELEMENT_INDEX,
				CANCEL_ELEMENT_INDEX,
				SKIPTUTORIAL_ELEMENT_INDEX,
				REPLAY_ELEMENT_INDEX,
				TRANSMISSION_ELEMENT_INDEX,
				OBJECTIVES_ELEMENT_INDEX,
				FIRST_PORTRAIT_ELEMENT_INDEX)
        {
        }
Example #54
0
		public OkDialog (UIScreen parent, Mpq mpq, string message)
			: base (parent, mpq, "glue\\PalNl", Builtins.rez_GluPOkBin)
		{
			background_path = "glue\\PalNl\\pOPopup.pcx";
			this.message = message;
		}
Example #55
0
		public Sprite (Mpq mpq, int sprite_entry, byte[] palette, int x, int y)
		{
			this.mpq = mpq;
			this.palette = palette;

			images_entry = GlobalResources.Instance.SpritesDat.ImagesDatEntries [sprite_entry];
			//			Console.WriteLine ("image_dat_entry == {0}", images_entry);

			uint grp_index = GlobalResources.Instance.ImagesDat.GrpIndexes [images_entry];
			//			Console.WriteLine ("grp_index = {0}", grp_index);
			grp_path = GlobalResources.Instance.ImagesTbl[(int)grp_index-1];
			//			Console.WriteLine ("grp_path = {0}", grp_path);

			grp = (Grp)mpq.GetResource ("unit\\" + grp_path);

			iscript_entry = GlobalResources.Instance.ImagesDat.IScriptIndexes [images_entry];
			script_entry_offset = GlobalResources.Instance.IScriptBin.GetScriptEntryOffset (iscript_entry);

			Console.WriteLine ("new sprite: unit\\{0} @ {1}x{2} (image {3}, iscript id {4}, script_entry_offset {5:X})",
					   grp_path, x, y, images_entry, iscript_entry, script_entry_offset);

			this.buf = GlobalResources.Instance.IScriptBin.Contents;

			/* make sure the offset points to "SCPE" */
			if (Util.ReadDWord (buf, script_entry_offset) != 0x45504353)
				Console.WriteLine ("invalid script_entry_offset");

			SetPosition (x,y);
		}
Example #56
0
		public NetworkDialog (UIScreen parent, Mpq mpq)
			: base (parent, mpq, "glue\\Palmm", Builtins.rez_NetDlgBin)
		{
			background_path = null;
		}
Example #57
0
 public static void PlayMusic(Mpq mpq, string resourcePath, int numLoops)
 {
     Stream stream = (Stream)mpq.GetResource (resourcePath);
     if (stream == null)
         return;
     Sound s = GuiUtil.SoundFromStream (stream);
     s.Play (true);
 }
Example #58
0
		public SpeedDialog (UIScreen parent, Mpq mpq)
			: base (parent, mpq, "glue\\Palmm", Builtins.rez_SpdDlgBin)
		{
			background_path = null;
		}
Example #59
0
 public static void PlaySound(Mpq mpq, string resourcePath)
 {
     Stream stream = (Stream)mpq.GetResource (resourcePath);
     if (stream == null)
         return;
     Sound s = GuiUtil.SoundFromStream (stream);
     s.Play();
 }