static void Main(string[] args) { Glance.BuildSetting.outputDir = @"D:\Glc\out\"; Glance.BuildSetting.sourceDir = @"D:\Glc\src\"; Glance.BuildSetting.includeDir = @"D:\Glc\include\"; Glance.BuildSetting.libDir = @"D:\Glc\lib\SFML\"; Glance.BuildSetting.settingsDir = @"D:\Glc\settings\"; Glance.BuildSetting.scriptsDir = @"D:\Glc\scripts\"; Glance.BuildSetting.compilerDir = @"D:\Glc\compiler\LLVM\bin\"; Glance.BuildSetting.libs.Add(@"sfml-graphics.lib"); Glance.BuildSetting.libs.Add(@"sfml-window.lib"); Glance.BuildSetting.libs.Add(@"sfml-system.lib"); Glance.BuildSetting.libs.Add(@"sfml-audio.lib"); Glance.BuildSetting.libs.Add(@"sfml-network.lib"); Glance.BuildSetting.compilerKeys = @"/EHsc " + " /I" + Glance.BuildSetting.sourceDir + " /I" + Glance.BuildSetting.includeDir; Glance.BuildSetting.linkerKeys = @"/LIBPATH:" + Glance.BuildSetting.libDir; Glance.BuildSetting.exeName = "main.exe"; Glance.BuildSetting.isClearSrcDir = true; Glance.BuildSetting.isGenerateCode = true; Glance.BuildSetting.isRecompile = true; Glance.BuildSetting.isRunAppAfterCompiling = true; Glance.Init(); //------------------------------------------------ game(); }
internal override string GetCppConstructorBody() { string code = ""; foreach (var i in Frames) { code += Glance.NameSetting.AnimationName + ".emplaceFrame(" + Glance.ToCppString(i.FilePath) + ", " + i.Duration.ToString("0.00").Replace(',', '.') + "f);\n"; } return(_GetProcessed(Glance.templates["Com:Animation:ConstructorBody"].Replace("#SpriteFrames#", code))); }
static void game() { //-------------Client code starts here var scene = new Scene(); var layer1 = new Layer(); layer1.ClassName = "ObjectsLayer"; var enemyLayer = new Layer(); enemyLayer.ClassName = "EnemyLayer"; var hero = new RenderableObject(new Vec2(400, 300)); hero.ClassName = "Hero"; var graph = new Glc.Component.GraphicalComponent.Animation(Glc.Component.GraphicalComponent.AnimationType.Cyclic); graph.AddFrame(new SpriteFrame(@"resources\soldier\Soldier1.png", 400)); graph.AddFrame(new SpriteFrame(@"resources\soldier\Soldier2.png", 400)); hero.GraphComponent = graph; hero.AddComponent(new Glc.Component.Script(@"player.gcs")); var bullet = new RenderableObject(new Vec2()); bullet.ClassName = "Bullet"; bullet.GraphComponent = new Glc.Component.GraphicalComponent.Sprite(@"resources\bullet.jpg"); bullet.AddComponent(new Glc.Component.Script(@"bullet.gcs")); bullet.AddComponent(new Glc.Component.Collider(Glc.Component.Collider.Type.Circle).SetRadius(5)); bullet.IsRenderableAtStart = false; Random rand = new Random(); for (var i = 0; i < 70; ++i) { var enemy = new Glc.RenderableObject(new Vec2((float)rand.Next(0, 800), (float)600.54)); var eGraph = new Glc.Component.GraphicalComponent.Animation(Glc.Component.GraphicalComponent.AnimationType.Cyclic); eGraph.AddFrame(new SpriteFrame(@"resources\enemy\enemy1.png", (float)rand.Next(300, 600))); eGraph.AddFrame(new SpriteFrame(@"resources\enemy\enemy2.png", (float)rand.Next(300, 600))); enemy.GraphComponent = eGraph; enemy.AddComponent(new Glc.Component.Collider(Glc.Component.Collider.Type.Rectangle).SetSize(new Vec2(54, 94))); enemy.AddComponent(new Glc.Component.Script(@"enemy.gcs")); enemyLayer.AddObject(enemy); } layer1.AddObject(hero); layer1.AddObject(bullet); scene.AddLayer(enemyLayer); scene.AddLayer(layer1); Glance.AddScene(scene); //-------------Client code ends here Glance.Build(); Console.ReadKey(); }
static void emptyGame() { var scene = new Scene(); var layer = new Layer(); Glance.AddScene(scene); scene.AddLayer(layer); //-------------Client code ends here Glance.Build(); Console.ReadKey(); }
private async Task itemInit(CityViewModel item, HeWeatherModel weather) { item.NowCondition = weather.NowWeather.Now.Condition; item.Temperature = weather.NowWeather.Temprature; string p = TemperatureDecoratorConverter.GetCurrentDeco(); item.Decorator = p; var utcOffset = weather.Location.UpdateTime - weather.Location.UtcTime; var current = DateTimeHelper.ReviseLoc(utcOffset); var todayIndex = Array.FindIndex(weather.DailyForecast, x => { return(x.Date.Date == current.Date); }); var hourIndex = Array.FindIndex(weather.HourlyForecast, x => { return((x.DateTime - current).TotalSeconds > 0); }); if (todayIndex < 0) { todayIndex = 0; } if (hourIndex < 0) { hourIndex = 0; } item.High = weather.DailyForecast[todayIndex].HighTemp; item.Low = weather.DailyForecast[todayIndex].LowTemp; var isNight = Generator.CalcIsNight(weather.Location.UpdateTime, weather.DailyForecast[todayIndex].SunRise, weather.DailyForecast[todayIndex].SunSet, new Models.Location(item.latitude, item.longitude)); item.Glance = Glance.GenerateGlanceDescription(weather, isNight, settings.Preferences.TemperatureParameter, DateTime.Now); var uri = await settings.Immersive.GetCurrentBackgroundAsync(weather.NowWeather.Now.Condition, isNight); if (uri != null) { try { item.Background = new BitmapImage(uri); } catch (Exception) { } } item.data = null; }
internal override List <string> GetCppConstructor() { switch (type) { case Type.Rectangle: return(Glance.templates["Com:Collider:Constructor"] .Replace("#ColliderName#", Glance.NameSetting.ColliderName) .Replace("#Size#", size.GetCppCtor()) .Split(',').gForEach(x => x.Trim()).ToList()); case Type.Circle: return(Glance.templates["Com:Collider:Constructor"] .Replace("#ColliderName#", Glance.NameSetting.ColliderName) .Replace("#Size#", Glance.floatToString(radius)) .Split(',').gForEach(x => x.Trim()).ToList()); default: throw new Exception("Glc.Component.Collider.GetCppConstructor has been hacked, param type is: " + type.ToString()); } }
public void _Init() { if (_isInitializated) { return; } // var strings = File.ReadAllLines(_owner.FileName); bool isInsideMethod = false; byte tabs = 0; var variables = new Dictionary <Glance.FieldsAccessType, List <string> >(); List <string> constructors = new List <string>(); string constructorBody = ""; string currentMethodSignature = null; Region currentRegion = Region.Undefined; Glance.FieldsAccessType currentAcessType = Glance.FieldsAccessType.Public; foreach (var i in strings) { var str = i.Trim(); if (str == "") { continue; } if (str.Length > 2) { if (str.Substring(0, 2) == "//") { continue; } } if (str.Contains(Glance.NameSetting.ScriptVariablesRegionName)) { currentRegion = Region.Variables; currentAcessType = Glance.FieldsAccessType.Public; continue; } if (str.Contains(Glance.NameSetting.ScriptMethodsRegionName)) { currentRegion = Region.Methods; currentAcessType = Glance.FieldsAccessType.Public; continue; } if (str.Contains(Glance.NameSetting.ScriptConstructorsRegionName)) { currentRegion = Region.Constructor; continue; } if (str.Contains(Glance.NameSetting.ScriptConstructorBodyRegionName)) { currentRegion = Region.ConstructorBody; continue; } if (currentRegion == Region.Variables) { if (str.Contains("public:")) { currentAcessType = Glance.FieldsAccessType.Public; continue; } if (str.Contains("private:")) { currentAcessType = Glance.FieldsAccessType.Private; continue; } var tmp = new List <string>(); tmp.Add(str.Replace(";", "")); variables.gAddOrMerge(currentAcessType, tmp); } if (currentRegion == Region.Constructor) { constructors.AddRange(str.Split(',').gForEach(x => x.Trim())); //add Trimmed array } if (currentRegion == Region.ConstructorBody) { constructorBody += str; } if (currentRegion == Region.Methods) { if (!isInsideMethod) { //if we are not inside of method, then we are at signature of this method if (Glance.getLastChar(str) != '{') { throw new Exception("'{' not at the end of line with method signature, signature is: " + str); } if (str.Contains("public:")) { currentAcessType = Glance.FieldsAccessType.Public; continue; } if (str.Contains("private:")) { currentAcessType = Glance.FieldsAccessType.Private; continue; } currentMethodSignature = str.Substring(0, str.Length - 1); //cut '{' ++tabs; isInsideMethod = true; if (MethodsImplementations.ContainsKey(currentMethodSignature)) { MethodsImplementations[currentMethodSignature] += ""; } else { MethodsImplementations.Add(currentMethodSignature, ""); } continue; } if (isInsideMethod) { if (str.Contains("{")) { ++tabs; } if (str.Contains("}")) { --tabs; } if (tabs == 0) { isInsideMethod = false; continue; } if (MethodsImplementations.ContainsKey(currentMethodSignature)) { MethodsImplementations[currentMethodSignature] += str + '\n'; } else { MethodsImplementations.Add(currentMethodSignature, str + '\n'); } } } } //foreach Constructors = constructors; ConstructorBody = constructorBody; Variables = variables; OnUpdate = MethodsImplementations[Glance.NameSetting.ScriptOnUpdateSignature]; OnStart = MethodsImplementations[Glance.NameSetting.ScriptOnStartSignature]; MethodsImplementations.Remove(Glance.NameSetting.ScriptOnStartSignature); MethodsImplementations.Remove(Glance.NameSetting.ScriptOnUpdateSignature); if (MethodsImplementations.ContainsKey("")) { MethodsImplementations.Remove(""); } MethodsDeclarations.Add(Glance.FieldsAccessType.Public, MethodsImplementations.Keys.ToList()); _isInitializated = true; } //_Init()
internal async void Pin(IList <object> selectedItems) { if (selectedItems == null || selectedItems.Count == 0) { return; } foreach (CityViewModel item in selectedItems) { SecondaryTile s = new SecondaryTile(item.Id, item.City, item.Id, new Uri("ms-appx:///Assets/Square150x150Logo.png"), TileSize.Default); var elem = s.VisualElements; elem.ShowNameOnSquare150x150Logo = true; elem.ShowNameOnSquare310x310Logo = true; elem.ShowNameOnWide310x150Logo = true; elem.Square310x310Logo = new Uri("ms-appx:///Assets/Square310x310Logo.png"); elem.Square44x44Logo = new Uri("ms-appx:///Assets/Square44x44Logo.png"); elem.Square71x71Logo = new Uri("ms-appx:///Assets/Square71x71Logo.png"); elem.Wide310x150Logo = new Uri("ms-appx:///Assets/Wide310x150Logo.png"); await s.RequestCreateAsync(); var index = Array.FindIndex(settings.Cities.SavedCities, x => { return(x.Id == item.Id); }); CitySettingsModel currentCity; if (index == -1 && settings.Cities.LocatedCity != null) { settings.Cities.LocatedCity.IsPinned = true; currentCity = settings.Cities.LocatedCity; } else { settings.Cities.SavedCities[index].IsPinned = true; currentCity = settings.Cities.SavedCities[index]; } var t = ThreadPool.RunAsync(async(work) => { string resstr; try { resstr = await settings.Cities.ReadDataAsync(item.Id.IsNullorEmpty() ? item.City : item.Id, settings.Preferences.DataSource); } catch (Exception) { resstr = await Request.GetRequestAsync(settings, item.Id, item.City, item.longitude, item.latitude, item.zmw); } if (!resstr.IsNullorEmpty()) { var weather = HeWeatherModel.Generate(resstr, settings.Preferences.DataSource); if (weather == null || weather.DailyForecast == null || weather.HourlyForecast == null) { return; } var utcOffset = weather.Location.UpdateTime - weather.Location.UtcTime; var current = DateTimeHelper.ReviseLoc(utcOffset); var todayIndex = Array.FindIndex(weather.DailyForecast, x => { return(x.Date.Date == current.Date); }); var hourIndex = Array.FindIndex(weather.HourlyForecast, x => { return((x.DateTime - current).TotalSeconds > 0); }); if (todayIndex < 0) { todayIndex = 0; } if (hourIndex < 0) { hourIndex = 0; } var isNight = Generator.CalcIsNight(weather.Location.UpdateTime, weather.DailyForecast[todayIndex].SunRise, weather.DailyForecast[todayIndex].SunSet, new Models.Location(currentCity.Latitude, currentCity.Longitude)); var glanceFull = Glance.GenerateGlanceDescription(weather, isNight, settings.Preferences.TemperatureParameter, DateTime.Now); var glance = Glance.GenerateShortDescription(weather, isNight); var uri = await settings.Immersive.GetCurrentBackgroundAsync(weather.NowWeather.Now.Condition, isNight); Sender.CreateSubTileNotification(await Generator.CreateAll(currentCity, weather, current), item.Id); } }); } }
internal override List <string> GetCppConstructor() { return(Glance.templates["Com:Sound:Constructor"]. Replace("#FileName#", Glance.ToCppString(FileName)).Split(',').gForEach(x => x.Trim()).ToList()); }
internal override string GetCppConstructorBody() { return(Glance.templates["Com:Sprite:ConstructorBody"].Replace("#FileName#", Glance.ToCppString(FileName))); }