// Use this for initialization void Start() { // canvas 作成 songlist = GameObject.Find("SongButton"); GameObject button = (GameObject)Resources.Load("Prefabs/MapSelect/Button"); DirectoryInfo dir = new DirectoryInfo(Setting.SongsPath + "map"); FileInfo[] info = dir.GetFiles("*.senshythm"); foreach (FileInfo f in info) { MapParam mapdata = MapParam.ReadData(f.Name); GameObject ButtonObj = Instantiate(button, new Vector3(), Quaternion.identity); ButtonObj.transform.SetParent(songlist.transform, false); ButtonObj.name = f.Name; btn = ButtonObj.GetComponent <Button>(); btn.onClick.AddListener(btn.GetComponent <GameStart>().OnClick); GameObject title = ButtonObj.transform.Find("Title").gameObject; GameObject artist = ButtonObj.transform.Find("Artist").gameObject; title.GetComponent <Text>().text = $"{mapdata.Title} {mapdata.Length/60:D2}:{mapdata.Length%60:D2}"; artist.GetComponent <Text>().text = $"{mapdata.Artist} // [{mapdata.Diffname}] create by {mapdata.Creator}"; } }
public static MapParam ReadData(string filename, bool hasNotes = false) { MapParam readParam = new MapParam(); readParam.BPMs = new List <BPM>(); if (hasNotes) { readParam.Notes = new List <Note>(); } StringReader strReader = MapParam.GetStringReader(filename); int readOption = 0; for (string line = strReader.ReadLine(); line != null; line = strReader.ReadLine()) { if (line.Equals("[metadata]")) { readOption = 1; } else if (line.Equals("[BPMs]")) { readOption = 2; } else if (line.Equals("[Notes]")) { readOption = 3; } else { readParam.SetParam(line, readOption, hasNotes); } } return(readParam); }
public void ParameterMapping(SpecPrototype prototype, string commandName, ref string name, out string attribute, out string type) { attribute = null; type = null; foreach (var map in parameterNameMaps) { if (map is MapParam) { MapParam param = (MapParam)map; if (param.CommandTargetRegex == null || param.CommandTargetRegex.IsMatch(commandName) && param.IsMatch(prototype.Declaration.Name)) { name = param.Replace(name); if (!string.IsNullOrEmpty(param.Attribute)) { attribute = param.Attribute; } if (!string.IsNullOrEmpty(param.Type)) { type = param.Type; } } } else { name = map.Replace(name); } } }
/// <summary> Updates the overlay image. </summary> /// <param name="forceUpdate"> True, if the update should be forced even if the viewport didn't change. </param> private void UpdateOverlay(bool forceUpdate) { if (timer != null) { timer.Dispose(); timer = null; } var mapParam = GetMapParam(); if (!forceUpdate && mapParam == lastParam) { return; } // reset existing map map objects UpdateMapObjects?.Invoke(null, new Size()); lastParam = mapParam; mapParam.Index = ++index; if (worker != null) { worker.CancelAsync(); worker.DoWork -= Worker_DoWork; worker = null; } if (mapParam.Width < 32 || mapParam.Height < 32 || MinLevel > MapView.FinalZoom) { mapImage.Source = null; return; } if (!MapView.Printing) { worker = new BackgroundWorker(); worker.DoWork += Worker_DoWork; worker.WorkerSupportsCancellation = true; worker.RunWorkerAsync(mapParam); } else { try { var bytes = GetImageBytes(mapParam, out var mapObjects); DisplayImage(bytes, mapObjects, mapParam); } catch { // ignored } } }
public void CustomButton() { selectedMap = ScriptableObject.CreateInstance(typeof(MapParam)) as MapParam; selectedMap.name = ""; selectedMap.octave = -1; selectedMap.persistance = -1f; selectedMap.lacunarity = -1f; selectedMap.seed = -1; selectedMap.chunks = -1; selectedMap.highCoeff = -1; selectedMap.regions = new List <TerrainType>(); }
public override int GetHashCode() { int hash = 1; if (mapParam_ != null) { hash ^= MapParam.GetHashCode(); } if (navigationLane_ != null) { hash ^= NavigationLane.GetHashCode(); } return(hash); }
/// <summary> /// Loads an map image for the specified map parameters. /// </summary> /// <param name="mapParam">Map parameters (map section and image size)</param> /// <param name="mapObjects"> Set of map objects. </param> /// <returns>The bytes of the encoded map image.</returns> private byte[] GetImageBytes(MapParam mapParam, out IEnumerable <IMapObject> mapObjects) { mapObjects = null; MapParam reqParam = mapParam.Scale(untiledProvider as ITiledProvider); if (!reqParam.IsSizeInRange(new Size(32, 32), MaxRequestSize)) { return(null); } Stream stream; if (untiledProvider is IUntiledProviderWithMapObjects untiledProviderWithMapObjects) { stream = untiledProviderWithMapObjects.GetImageStreamAndMapObjects( reqParam.Left, reqParam.Top, reqParam.Right, reqParam.Bottom, (int)reqParam.Width, (int)reqParam.Height, out mapObjects); } else { stream = untiledProvider.GetImageStream(reqParam.Left, reqParam.Top, reqParam.Right, reqParam.Bottom, (int)reqParam.Width, (int)reqParam.Height); } using (stream) { if (stream == null) { return(null); } if (mapParam == reqParam) { return(stream.GetBytes()); } // mapParam != reqParam ==> this is the case if image has been // scaled through mapParam.Scale call above. Must resize image. using (var stmResized = stream.ResizeImage((int)mapParam.Width, (int)mapParam.Height)) return(stmResized.GetBytes()); } }
public void SetMapChoice() { mapChoice.ClearOptions(); mapParams.Clear(); foreach (string map in dataFiles.mapDatas) { string filePath = Path.Combine(Application.persistentDataPath, "Maps", map); if (!File.Exists(filePath)) { string dataAsJson = File.ReadAllText(filePath + ".json"); MapParam tmp = new MapParam(); JsonUtility.FromJsonOverwrite(dataAsJson, tmp); mapParams.Add(tmp); } } mapChoice.AddOptions(dataFiles.mapDatas); if (defaultMap.Count > 0) { selectedMap = defaultMap[0]; } }
public void MergeFrom(RelativeMapConfig other) { if (other == null) { return; } if (other.mapParam_ != null) { if (mapParam_ == null) { mapParam_ = new global::Apollo.RelativeMap.MapGenerationParam(); } MapParam.MergeFrom(other.MapParam); } if (other.navigationLane_ != null) { if (navigationLane_ == null) { navigationLane_ = new global::Apollo.RelativeMap.NavigationLaneConfig(); } NavigationLane.MergeFrom(other.NavigationLane); } }
/// <summary> Get the map parameters object for the current viewport. </summary> /// <returns> The map parameters instance. </returns> private MapParam GetMapParam() { MapRectangle rect = MapView.FinalEnvelope; var mapParam = new MapParam(rect.West, rect.South, rect.East, rect.North, MapView.ActualWidth, MapView.ActualHeight); if (mapParam.Width == 0 || mapParam.Height == 0) { return(mapParam); } // clip the rectangle to the maximum rectangle if (mapParam.Left < EnvMinX || mapParam.Right > EnvMaxX || mapParam.Top < EnvMinY || mapParam.Bottom > EnvMaxY) { double leftClipped = Math.Max(EnvMinX, mapParam.Left); double rightClipped = Math.Min(EnvMaxX, mapParam.Right); double topClipped = Math.Max(EnvMinY, mapParam.Top); double bottomClipped = Math.Min(EnvMaxY, mapParam.Bottom); double widthClipped = mapParam.Width * (rightClipped - leftClipped) / (mapParam.Right - mapParam.Left); double heightClipped = mapParam.Height * (bottomClipped - topClipped) / (mapParam.Bottom - mapParam.Top); mapParam = new MapParam(leftClipped, topClipped, rightClipped, bottomClipped, widthClipped, heightClipped); } // resize if > MaxSize if (mapParam.Width <= MaxRequestSize.Width && mapParam.Height <= MaxRequestSize.Height) { return(mapParam); } double ratio = Math.Min(MaxRequestSize.Height / mapParam.Height, MaxRequestSize.Width / mapParam.Width); mapParam.Width *= ratio; mapParam.Height *= ratio; return(mapParam); }
public static void Set(string filename) { Song = MapParam.ReadData(filename, true); }
public DSMap(MapParam mapParam) { this.mapParam = mapParam; }
/// <summary> Display the loaded image. </summary> /// <param name="buffer"> The byte array containing the image data. </param> /// <param name="mapObjects"> Set of map objects. </param> /// <param name="mapParam"> The corresponding map parameters object. </param> private void DisplayImage(byte[] buffer, IEnumerable <IMapObject> mapObjects, MapParam mapParam) { // map viewport changed already if (mapParam.Index != index) { return; } lastZoom = MapView.FinalZoom; mapImage.Width = mapParam.Right - mapParam.Left; mapImage.Height = mapParam.Bottom - mapParam.Top; mapImage.Opacity = 1; SetLeft(mapImage, mapParam.Left + MapView.OriginOffset.X); SetTop(mapImage, -mapParam.Bottom + MapView.OriginOffset.Y); mapImage.Tag = mapParam; if (buffer == null) { mapImage.Source = null; return; } using (var stream = new MemoryStream(buffer)) using (var wrapper = new WrappingStream(stream)) { var bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.StreamSource = wrapper; bitmapImage.CacheOption = BitmapCacheOption.OnLoad; bitmapImage.EndInit(); bitmapImage.Freeze(); mapImage.Source = bitmapImage; } UpdateMapObjects?.Invoke(mapObjects, new Size(mapParam.Width, mapParam.Height)); }
public void SetDropDownMap(int n) { selectedMap = mapParams[n]; }