Ejemplo n.º 1
0
        protected override void DoMouseMoveEvent(MouseMoveEventArgs eventArgs)
        {
            base.DoMouseMoveEvent(eventArgs);

            fMapHint = "";
            SearchResult res = SearchMapLocation(eventArgs.X, eventArgs.Y);

            if (res != null)
            {
                LayerEntry eLayer = (LayerEntry)GlobalVars.nwrDB.GetEntry(res.LID);
                NWField    fld    = GlobalVars.nwrGame.GetField(res.LID, res.FieldX, res.FieldY);
                fMapHint = eLayer.Name;
                if (fld.Visited)
                {
                    string Land = fld.LandName;
                    if (fMapHint.CompareTo(Land) != 0 && Land.CompareTo("") != 0)
                    {
                        fMapHint = fMapHint + " - " + Land;
                    }
                }
                else
                {
                    fMapHint = "";
                }
            }
        }
Ejemplo n.º 2
0
        public NWField(NWGameSpace space, NWLayer layer, ExtPoint coords)
            : base(StaticData.FieldWidth, StaticData.FieldHeight)
        {
            fSpace  = space;
            fLayer  = layer;
            fCoords = coords;

            fCreatures     = new CreaturesList(this, true);
            fItems         = new ItemsList(this, true);
            fEffects       = new EffectsList(this, true);
            fEmitters      = new EmitterList();
            ValidCreatures = new List <int>();

            if (Layer != null)
            {
                LayerEntry layerEntry = (LayerEntry)GlobalVars.nwrDB.GetEntry(Layer.EntryID);
                fEntry = layerEntry.GetFieldEntry(fCoords.X, fCoords.Y);

                EntryID = fEntry.GUID;

                fLandEntry = (LandEntry)GlobalVars.nwrDB.FindEntryBySign(fEntry.LandSign);
                LandID     = fLandEntry.GUID;

                PrepareCreatures();
            }
            else
            {
                fEntry     = null;
                EntryID    = -1;
                fLandEntry = null;
                LandID     = -1;
            }
        }
Ejemplo n.º 3
0
 public LayerEntryTemplate(LayerEntry layerEntry)
 {
     SourceFile       = layerEntry.SourceFile.ToAbsolutePath().ToString();
     ExtractionPath   = layerEntry.ExtractionPath.ToString();
     LastModifiedTime = Files.GetLastModifiedTime(layerEntry.SourceFile);
     Permissions      = layerEntry.Permissions.ToOctalString();
 }
Ejemplo n.º 4
0
        private static SearchResult SearchMapLocation(int aX, int aY)
        {
            aX -= 8;
            aY -= 8;

            int num = GlobalVars.nwrGame.LayersCount;

            for (int idx = 0; idx < num; idx++)
            {
                NWLayer    layer      = GlobalVars.nwrGame.GetLayer(idx);
                LayerEntry layerEntry = layer.Entry;

                ExtRect rt = ExtRect.Create(layerEntry.MSX, layerEntry.MSY, layerEntry.MSX + (layerEntry.W << 5), layerEntry.MSY + layerEntry.H * 30);

                if (rt.Contains(aX, aY))
                {
                    int xx = (aX - layerEntry.MSX) / 32;
                    int yy = (aY - layerEntry.MSY) / 30;

                    NWField fld = layer.GetField(xx, yy);
                    if (fld != null)
                    {
                        SearchResult result = new SearchResult();
                        result.LID    = layerEntry.GUID;
                        result.FieldX = xx;
                        result.FieldY = yy;
                        return(result);
                    }
                }
            }

            return(null);
        }
Ejemplo n.º 5
0
    public void AddLayerFromImagePath(string path)
    {
        Layer newLayer = new Layer(nextLayerSuffix);

        layers.Add(newLayer);

        string newLayerName = newLayerPrefix + " " + newLayer.id;

        // Create the 3D object
        newLayer.ingameObject      = Instantiate(masterAsset, new Vector3(0, 0, 0), Camera.main.transform.rotation, layerParent);
        newLayer.ingameObject.name = newLayerPrefix + " " + newLayer.id;

        // Change the meshes' texture
        Texture2D textureFromPath = DecodeImageFromPath(path);
        Renderer  meshRenderer    = newLayer.ingameObject.GetComponentInChildren <Renderer>();

        meshRenderer.material.mainTexture          = textureFromPath;
        meshRenderer.material.mainTexture.wrapMode = TextureWrapMode.Clamp;
        meshRenderer.material.renderQueue          = newLayer.id;

        // New UI element
        newLayer.uiElem      = Instantiate(layerUIElem, layersList.transform);
        newLayer.uiElem.name = newLayerName;

        LayerEntry layerEntry = newLayer.uiElem.GetComponent <LayerEntry>();

        if (layerEntry)
        {
            layerEntry.SetLayer(newLayer);
            layerEntry.SetText(newLayerName);
            layerEntry.SetPreview(textureFromPath);
        }

        nextLayerSuffix++;
    }
Ejemplo n.º 6
0
        private void OpenClick(object sender, RoutedEventArgs e)
        {
            LayersLb.Items.Clear();
            ContentCanvas.Children.Clear();

            var ofd = new OpenFileDialog();

            if (ofd.ShowDialog() == true)
            {
                var        file       = File.ReadAllLines(ofd.FileName);
                LayerEntry layerEntry = null;
                foreach (var line in file)
                {
                    if (line.Contains("~"))
                    {
                        layerEntry = new LayerEntry(line.Replace("~", ""));
                        LayersLb.Items.Add(layerEntry);
                    }
                    else
                    {
                        var element = XamlReader.Parse(line) as UserControl;
                        if (element != null)
                        {
                            layerEntry?.Children.Add(element);
                            ContentCanvas.Children.Add(element);
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public NWLayer(NWGameSpace space, int layerID)
            : base(0, 0)
        {
            fSpace = space;

            fEntry = (LayerEntry)GlobalVars.nwrDB.GetEntry(layerID);
            fW     = fEntry.W;
            fH     = fEntry.H;

            Resize(fW * StaticData.FieldWidth, fH * StaticData.FieldHeight);

            EntryID = layerID;

            fFields = new NWField[fH, fW];

            for (int y = 0; y < fH; y++)
            {
                for (int x = 0; x < fW; x++)
                {
                    fFields[y, x] = new NWField(space, this, new ExtPoint(x, y));
                }
            }

            fEffects = new EffectsList(this, true);
        }
Ejemplo n.º 8
0
        public void InitLayer()
        {
            LayerEntry layer_entry = (LayerEntry)GlobalVars.nwrDB.GetEntry(EntryID);
            string     entry_sign  = layer_entry.Sign;

            try {
                for (int y = 0; y < fH; y++)
                {
                    for (int x = 0; x < fW; x++)
                    {
                        fFields[y, x].Clear();
                        GlobalVars.nwrWin.ProgressStep();
                    }
                }

                if (EntryID == GlobalVars.Layer_Svartalfheim1 || EntryID == GlobalVars.Layer_Svartalfheim2)
                {
                    UniverseBuilder.Build_Dungeon(this, AreaRect);
                }
                else
                {
                    if (EntryID == GlobalVars.Layer_Svartalfheim3)
                    {
                        ExtRect area = ExtRect.Create(0, 0, StaticData.FieldWidth - 1, StaticData.FieldHeight * 3 - 1);
                        UniverseBuilder.Build_Dungeon(this, area);

                        area = ExtRect.Create(StaticData.FieldWidth, StaticData.FieldHeight * 2, StaticData.FieldWidth * 2 - 1, StaticData.FieldHeight * 3 - 1);
                        UniverseBuilder.Build_Dungeon(this, area);

                        area = ExtRect.Create(StaticData.FieldWidth, 0, StaticData.FieldWidth * 3 - 1, StaticData.FieldHeight * 2 - 1);
                        UniverseBuilder.Build_Caves(this, area);
                    }
                }

                for (int y = 0; y < fH; y++)
                {
                    for (int x = 0; x < fW; x++)
                    {
                        fFields[y, x].InitField();
                        GlobalVars.nwrWin.ProgressStep();
                    }
                }

                for (int y = 0; y < fH; y++)
                {
                    for (int x = 0; x < fW; x++)
                    {
                        fFields[y, x].Normalize();
                        GlobalVars.nwrWin.ProgressStep();
                    }
                }
            } catch (Exception ex) {
                Logger.Write("NWLayer.InitLayer(" + entry_sign + "): " + ex.Message);
            }
        }
Ejemplo n.º 9
0
        protected override void DoPaintEvent(BaseScreen screen)
        {
            base.DoPaintEvent(screen);

            int ax = 8;
            int ay = 8;

            screen.DrawImage(ax, ay, 0, 0, (int)fImage.Width, (int)fImage.Height, fImage, 255);

            screen.Font = CtlCommon.BgFont;
            screen.DrawText(ax + 40, ay + 25, BaseLocale.GetStr(RS.rs_WorldsTree), 0);
            screen.Font = CtlCommon.SmFont;

            int num = GlobalVars.nwrGame.LayersCount;

            for (int i = 0; i < num; i++)
            {
                NWLayer    layer = GlobalVars.nwrGame.GetLayer(i);
                LayerEntry lre   = layer.Entry;

                for (int y = 0; y < layer.H; y++)
                {
                    for (int x = 0; x < layer.W; x++)
                    {
                        if (layer.GetField(x, y).Visited)
                        {
                            GlobalVars.nwrWin.Resources.DrawImage(screen,
                                                                  ax + lre.MSX + (x << 5), ay + lre.MSY + y * 30,
                                                                  lre.IconsIndex + (y * lre.W + x), 255);
                        }
                    }
                }
            }

            Player     player     = GlobalVars.nwrGame.Player;
            LayerEntry layerEntry = ((LayerEntry)GlobalVars.nwrDB.GetEntry(player.LayerID));

            if (fMapCursor)
            {
                NWField  fld = (NWField)player.CurrentMap;
                ExtPoint f   = fld.Coords;
                GlobalVars.nwrWin.Resources.DrawImage(screen,
                                                      ax + layerEntry.MSX + (f.X << 5), ay + layerEntry.MSY + f.Y * 30,
                                                      StaticData.dbItfElements[(int)ItfElement.id_Cursor].ImageIndex, 255);
            }

            if (fMapHint.CompareTo("") != 0)
            {
                int tw = CtlCommon.SmFont.GetTextWidth(fMapHint);
                CtlCommon.SmFont.Color = Colors.Navy;

                //screen.drawText(ax + 304 + ((288 - tw) / 2), ay + 410, this.fMapHint, 0);
                screen.DrawText(ax + 58 + ((582 - tw) / 2), ay + 445, fMapHint, 0);
            }
        }
Ejemplo n.º 10
0
        private void layerSelector_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            LayerEntry        layerEntry = e.ClickedItem.Tag as LayerEntry;
            ToolStripMenuItem layerItem  = e.ClickedItem as ToolStripMenuItem;

            if (layerItem.Checked)
            {
                this.DeactivateLayer(layerEntry.LayerType);
            }
            else
            {
                this.ActivateLayer(layerEntry.LayerType);
            }

            layerItem.Checked = this.activeLayers.Any(l => l.GetType() == layerEntry.LayerType);
        }
        private void UpdateList()
        {
            Player player = new Player(null, null);

            try {
                for (int i = 0; i < MaxList; i++)
                {
                    string fn = NWGameSpace.GetSaveFile(NWGameSpace.SAVEFILE_PLAYER, i);

                    fFiles[i]       = new GameFile();
                    fFiles[i].Exist = File.Exists(fn);
                    if (fFiles[i].Exist)
                    {
                        fFiles[i].SaveTime = File.GetLastWriteTime(fn);

                        try {
                            NWGameSpace.LoadPlayer(i, player);

                            fFiles[i].PlayerName = player.Name;

                            int fx = player.Field.X;
                            int fy = player.Field.Y;

                            LayerEntry layer    = (LayerEntry)GlobalVars.nwrDB.GetEntry(player.LayerID);
                            string     landSign = layer.GetFieldEntry(fx, fy).LandSign;

                            LandEntry land = (LandEntry)GlobalVars.nwrDB.FindEntryBySign(landSign);
                            fFiles[i].LandName = land.Name;
                        } catch (Exception ex) {
                            Logger.Write("FilesWindow.refreshList.PlayerLoad(" + fn + "): " + ex.Message);
                            fFiles[i].PlayerName = "<error>";
                            fFiles[i].LandName   = "<error>";
                        }
                    }
                    else
                    {
                        fFiles[i].PlayerName = BaseLocale.GetStr(RS.rs_PlayerUnknown);
                        fFiles[i].LandName   = "-";
                        fFiles[i].SaveTime   = new DateTime();
                    }
                }
            } finally {
                player.Dispose();
            }
        }
Ejemplo n.º 12
0
        public void SetUp()
        {
            SystemPath folder = temporaryFolder.NewFolder().ToPath();
            SystemPath file1  = Files.CreateDirectory(folder.Resolve("files"));
            SystemPath file2  = Files.CreateFile(folder.Resolve("files").Resolve("two"));
            SystemPath file3  = Files.CreateFile(folder.Resolve("gile"));

            LayerEntry testLayerEntry1 = DefaultLayerEntry(file1, AbsoluteUnixPath.Get("/extraction/path"));
            LayerEntry testLayerEntry2 = DefaultLayerEntry(file2, AbsoluteUnixPath.Get("/extraction/path"));
            LayerEntry testLayerEntry3 = DefaultLayerEntry(file3, AbsoluteUnixPath.Get("/extraction/path"));
            LayerEntry testLayerEntry4 =
                new LayerEntry(
                    file3,
                    AbsoluteUnixPath.Get("/extraction/path"),
                    FilePermissions.FromOctalString("755"),
                    LayerConfiguration.DefaultModifiedTime);
            LayerEntry testLayerEntry5 =
                DefaultLayerEntry(file3, AbsoluteUnixPath.Get("/extraction/patha"));
            LayerEntry testLayerEntry6 =
                new LayerEntry(
                    file3,
                    AbsoluteUnixPath.Get("/extraction/patha"),
                    FilePermissions.FromOctalString("755"),
                    LayerConfiguration.DefaultModifiedTime);

            outOfOrderLayerEntries =
                ImmutableArray.Create(
                    testLayerEntry4,
                    testLayerEntry2,
                    testLayerEntry6,
                    testLayerEntry3,
                    testLayerEntry1,
                    testLayerEntry5);
            inOrderLayerEntries =
                ImmutableArray.Create(
                    testLayerEntry1,
                    testLayerEntry2,
                    testLayerEntry3,
                    testLayerEntry4,
                    testLayerEntry5,
                    testLayerEntry6);
        }
Ejemplo n.º 13
0
        public async Task TestGenerateSelector_fileModifiedAsync()
        {
            SystemPath layerFile = temporaryFolder.NewFolder("testFolder").ToPath().Resolve("file");

            Files.Write(layerFile, Encoding.UTF8.GetBytes("hello"));
            Files.SetLastModifiedTime(layerFile, FileTime.From(Instant.FromUnixTimeSeconds(0)));
            LayerEntry       layerEntry       = DefaultLayerEntry(layerFile, AbsoluteUnixPath.Get("/extraction/path"));
            DescriptorDigest expectedSelector =
                await GenerateSelectorAsync(ImmutableArray.Create(layerEntry)).ConfigureAwait(false);

            // Verify that changing modified time generates a different selector
            Files.SetLastModifiedTime(layerFile, FileTime.From(Instant.FromUnixTimeSeconds(1)));
            Assert.AreNotEqual(
                expectedSelector, await GenerateSelectorAsync(ImmutableArray.Create(layerEntry)).ConfigureAwait(false));

            // Verify that changing modified time back generates same selector
            Files.SetLastModifiedTime(layerFile, FileTime.From(Instant.FromUnixTimeSeconds(0)));
            Assert.AreEqual(
                expectedSelector,
                await GenerateSelectorAsync(ImmutableArray.Create(layerEntry)).ConfigureAwait(false));
        }
Ejemplo n.º 14
0
        private void InitLayerSelector()
        {
            this.layerSelector.DropDown.Closing -= this.layerSelector_Closing;
            this.layerSelector.DropDownItems.Clear();

            IEnumerable <Type> camViewStateTypeQuery =
                from t in DualityEditorApp.GetAvailDualityEditorTypes(typeof(CamViewLayer))
                where !t.IsAbstract
                select t;

            foreach (var pair in this.availLayers)
            {
                LayerEntry        layerEntry = new LayerEntry(pair.Key, pair.Value);
                ToolStripMenuItem layerItem  = new ToolStripMenuItem(layerEntry.LayerName);
                layerItem.Tag         = layerEntry;
                layerItem.ToolTipText = layerEntry.LayerDesc;
                layerItem.Checked     = this.activeLayers != null && this.activeLayers.Any(l => l.GetType() == layerEntry.LayerType);
                layerItem.Enabled     = !this.lockedLayers.Contains(layerEntry.LayerType);
                this.layerSelector.DropDownItems.Add(layerItem);
            }
            this.layerSelector.DropDown.Closing += this.layerSelector_Closing;
        }
Ejemplo n.º 15
0
        public void TestGenerateSelector_permissionsModified()
        {
            SystemPath layerFile = temporaryFolder.NewFolder("testFolder").ToPath().Resolve("file");

            Files.Write(layerFile, Encoding.UTF8.GetBytes("hello"));
            LayerEntry layerEntry111 =
                new LayerEntry(
                    layerFile,
                    AbsoluteUnixPath.Get("/extraction/path"),
                    FilePermissions.FromOctalString("111"),
                    LayerConfiguration.DefaultModifiedTime);
            LayerEntry layerEntry222 =
                new LayerEntry(
                    layerFile,
                    AbsoluteUnixPath.Get("/extraction/path"),
                    FilePermissions.FromOctalString("222"),
                    LayerConfiguration.DefaultModifiedTime);

            // Verify that changing permissions generates a different selector
            Assert.AreNotEqual(
                GenerateSelectorAsync(ImmutableArray.Create(layerEntry111)),
                GenerateSelectorAsync(ImmutableArray.Create(layerEntry222)));
        }
Ejemplo n.º 16
0
		private void InitLayerSelector()
		{
			this.layerSelector.DropDown.Closing -= this.layerSelector_Closing;
			this.layerSelector.DropDownItems.Clear();

			foreach (var pair in this.availLayers)
			{
				LayerEntry layerEntry = new LayerEntry(pair.Key, pair.Value);
				ToolStripMenuItem layerItem = new ToolStripMenuItem(layerEntry.LayerName);
				layerItem.Tag = layerEntry;
				layerItem.Checked = this.activeLayers != null && this.activeLayers.Any(l => l.GetType() == layerEntry.LayerType);
				layerItem.Enabled = !this.lockedLayers.Contains(layerEntry.LayerType);
				this.layerSelector.DropDownItems.Add(layerItem);
			}
			this.layerSelector.DropDown.Closing += this.layerSelector_Closing;
		}
Ejemplo n.º 17
0
		private void InitLayerSelector()
		{
			this.layerSelector.DropDown.Closing -= this.layerSelector_Closing;
			this.layerSelector.DropDownItems.Clear();

			IEnumerable<Type> camViewStateTypeQuery = 
				from t in DualityEditorApp.GetAvailDualityEditorTypes(typeof(CamViewLayer))
				where !t.IsAbstract
				select t;

			foreach (var pair in this.availLayers)
			{
				LayerEntry layerEntry = new LayerEntry(pair.Key, pair.Value);
				ToolStripMenuItem layerItem = new ToolStripMenuItem(layerEntry.LayerName);
				layerItem.Tag = layerEntry;
				layerItem.ToolTipText = layerEntry.LayerDesc;
				layerItem.Checked = this.activeLayers != null && this.activeLayers.Any(l => l.GetType() == layerEntry.LayerType);
				layerItem.Enabled = !this.lockedLayers.Contains(layerEntry.LayerType);
				this.layerSelector.DropDownItems.Add(layerItem);
			}
			this.layerSelector.DropDown.Closing += this.layerSelector_Closing;
		}
Ejemplo n.º 18
0
        private void AddLayerBtnClick(object sender, RoutedEventArgs e)
        {
            var layer = new LayerEntry($"Layer {LayersLb.Items.Count}");

            LayersLb.Items.Add(layer);
        }