public override void OnLevelLoaded(LoadMode mode) { if (ThreadingExtension.Instance != null) { ThreadingExtension.Instance.OnLevelLoaded(mode); } }
public override void OnLevelLoaded(LoadMode mode) { _mode = mode; // don't load mod in asset and map editor if (mode != LoadMode.LoadGame && mode != LoadMode.NewGame) return; // attach extended panels var view = UIView.GetAView(); var goBus = new GameObject("ExtendedBusPanel"); _extendedBusPanel = goBus.AddComponent<UITransportPanel>(); _extendedBusPanel.transform.parent = view.transform; _extendedBusPanel.Type = TransportInfo.TransportType.Bus; var goMetro = new GameObject("ExtendedMetroPanel"); _extendedMetroPanel = goMetro.AddComponent<UITransportPanel>(); _extendedMetroPanel.transform.parent = view.transform; _extendedMetroPanel.Type = TransportInfo.TransportType.Metro; var goTrain = new GameObject("ExtendedTrainPanel"); _extendedTrainPanel = goTrain.AddComponent<UITransportPanel>(); _extendedTrainPanel.transform.parent = view.transform; _extendedTrainPanel.Type = TransportInfo.TransportType.Train; HookIntoNativeUI(); }
public override void OnLevelLoaded(LoadMode mode) { EconomyManager em = Singleton<EconomyManager>.instance; DifficultyManager d = Singleton<DifficultyManager>.instance; if (mode == LoadMode.NewGame) { int moneyToAdd = (d.InitialMoney.Value - 70) * 100000; em.AddResource(EconomyManager.Resource.LoanAmount, moneyToAdd, ItemClass.Service.None, ItemClass.SubService.None, ItemClass.Level.None); } if (mode == LoadMode.NewGame || mode == LoadMode.LoadGame) { for (int i = 0; i < 3; i++) { EconomyManager.Bank bank = em.m_properties.m_banks[i]; EconomyManager.LoanInfo li = bank.m_loanOffers[0]; li.m_amount = (int)Math.Round(0.01f * li.m_amount * d.LoanMultiplier.Value); li.m_length = (int)Math.Round(0.01f * li.m_length * d.LoanMultiplier.Value); bank.m_loanOffers[0] = li; em.m_properties.m_banks[i] = bank; //DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, bank.m_bankName); } } Achievements.Update(); PrefabsManager.UpdatePrefabs(false); }
public override void OnLevelLoaded(LoadMode mode) { //Turns out this is the wrong way to do it. //ReplacePanels(); //And finally with the road options panel. RoadsOptionPanel[] roadsOptionPanels = UnityEngine.Object.FindObjectsOfType<RoadsOptionPanel>(); foreach (RoadsOptionPanel roadsOptionPanel in roadsOptionPanels) { GameObject roadsOptionsPanelObject = roadsOptionPanel.gameObject; RoadsOptionFinePanel roadsOptionFinePanel = roadsOptionsPanelObject.AddComponent<RoadsOptionFinePanel>(); Object.Destroy(roadsOptionPanel); } //Find the tool controller, re-make its tool list, and force a re-make of the ToolsModifierControl tool list. ToolController toolController = UnityEngine.Object.FindObjectOfType<ToolController>(); if (toolController != null) { NetToolFine netToolFine = toolController.gameObject.AddComponent<NetToolFine>(); NetTool netTool = toolController.gameObject.GetComponent<NetTool>(); FieldInfo toolControllerField = typeof(ToolController).GetField("m_tools", BindingFlags.Instance | BindingFlags.NonPublic); if (toolControllerField != null) toolControllerField.SetValue(toolController, toolController.GetComponents<ToolBase>()); FieldInfo toolModifierDictionary = typeof(ToolsModifierControl).GetField("m_Tools", BindingFlags.Static | BindingFlags.NonPublic); if (toolModifierDictionary != null) toolModifierDictionary.SetValue(null, null); } //if(mode == LoadMode.LoadAsset || mode == LoadMode.NewAsset) // || mode == LoadMode.LoadMap || mode == LoadMode.NewMap) { GameObject panelReplacer = UnityEngine.Object.Instantiate(new GameObject()); panelReplacer.AddComponent<PanelReplacer>(); panelReplacer.name = "PanelReplacer"; } }
public override void OnLevelLoaded(LoadMode mode) { if (mode != LoadMode.LoadGame && mode != LoadMode.NewGame && mode != LoadMode.NewMap && mode != LoadMode.LoadMap) return; lastLoadMode_ = mode; UIView view = UIView.GetAView(); UITabstrip tabStrip = null; whatsNewPanelGameObject = new GameObject("whatsNewPanel"); this.whatsNewPanel = whatsNewPanelGameObject.AddComponent<WhatsNewPanel>(); this.whatsNewPanel.transform.parent = view.transform; this.whatsNewPanel.Hide(); exportPanelGameObject = new GameObject("exportPanel"); this.exportPanel = exportPanelGameObject.AddComponent<ExportPanel>(); this.exportPanel.transform.parent = view.transform; this.exportPanel.whatsNewPanel = whatsNewPanel; this.exportPanel.Hide(); if (mode == LoadMode.NewGame || mode == LoadMode.LoadGame) { tabStrip = ToolsModifierControl.mainToolbar.component as UITabstrip; } else { tabStrip = UIView.Find<UITabstrip>("MainToolstrip"); } if (m_tabButton == null) { GameObject buttonGameObject = UITemplateManager.GetAsGameObject("MainToolbarButtonTemplate"); GameObject pageGameObject = UITemplateManager.GetAsGameObject("ScrollablePanelTemplate"); m_tabButton = tabStrip.AddTab("Road Namer", buttonGameObject, pageGameObject, new Type[] { }) as UIButton; UITextureAtlas atlas = CimToolsHandler.CimToolBase.SpriteUtilities.GetAtlas("CimtographerIcons"); m_tabButton.eventClicked += uiButton_eventClick; m_tabButton.tooltip = "Cimtographer"; m_tabButton.foregroundSpriteMode = UIForegroundSpriteMode.Fill; if (atlas != null) { m_tabButton.atlas = atlas; m_tabButton.normalFgSprite = "ToolbarFGIcon"; m_tabButton.focusedFgSprite = "ToolbarFGIcon"; m_tabButton.hoveredFgSprite = "ToolbarFGIcon"; m_tabButton.disabledFgSprite = "ToolbarFGIcon"; m_tabButton.pressedFgSprite = "ToolbarFGIcon"; m_tabButton.focusedBgSprite = "ToolbarBGFocused"; m_tabButton.hoveredBgSprite = "ToolbarBGHovered"; m_tabButton.pressedBgSprite = "ToolbarBGPressed"; } else { Debug.LogError("Cimtographer: Could not find atlas."); } } }
protected ModuleBase(bool iocContainerCanBeNull, LoadMode supportedModes = LoadMode.All, int priority = InitializationModulePriority - 1) { _iocContainerCanBeNull = iocContainerCanBeNull; _priority = priority; _supportedModes = supportedModes; _locker = new object(); }
public override void OnLevelLoaded(LoadMode mode) { if (!(mode == LoadMode.LoadGame || mode == LoadMode.NewGame)) { return; } try { LoadResources(); if (buildTool == null) { GameObject gameController = GameObject.FindWithTag("GameController"); buildTool = gameController.AddComponent<InGameTerrainTool>(); Texture2D tex = loadTextureFromAssembly("TerraformTool.builtin_brush_4.png", false); buildTool.m_atlas = terraform_atlas; buildTool.CreateButtons(); buildTool.m_brush = tex; buildTool.m_mode = InGameTerrainTool.Mode.Point; buildTool.enabled = false; GameObject.FindObjectOfType<ToolController>().Tools[0].enabled = true; } } catch (Exception e) { Debug.Log(e.ToString()); } }
public override void OnLevelLoaded(LoadMode mode) { base.OnLevelLoaded(mode); Pillars.Initialize(); NoPillarsUI.Initialize(); NoPillarsMonitor.Initialize(); }
/// <summary> /// Optional /// This core function will get called just after the Level - aka your map has been fully loaded. /// That means the game data has all been read from your file and the simulation is ready to go. /// </summary> /// <param name="mode">a LoadMode enum (ie newgame,newmap,loadgame,loadmap,newasset,loadassett)</param> public override void OnLevelLoaded(LoadMode mode) { base.OnLevelLoaded(mode); //call the original implemenation first if does anything... it doesn't actually but whatever maybe some day it might. CurrentLoadMode = mode; //save this guy for later. try { if (SomeModName.DEBUG_LOG_ON && SomeModName.DEBUG_LOG_LEVEL > 0) { Logger.dbgLog("LoadMode:" + mode.ToString()); } if (SomeModName.isEnabled == true) { // only setup gui when in a real game, not in the asset editor if (mode == LoadMode.LoadGame || mode == LoadMode.NewGame || mode==LoadMode.LoadMap ||mode==LoadMode.NewMap ) { if (SomeModName.DEBUG_LOG_ON) { Logger.dbgLog("Asset modes not detcted, setting up gui."); } SetupGui(); //setup gui } } else { //This should technically never happen, but why not account for it anyway. if (SomeModName.DEBUG_LOG_ON) { Logger.dbgLog("We fired when we were not even enabled active??"); } RemoveGui(); } } catch(Exception ex) { Logger.dbgLog("Error:", ex, true); } }
public override sealed void OnLevelLoaded(LoadMode mode) { _mode = mode; // Don't load in asset and map editor if (mode != LoadMode.LoadGame && mode != LoadMode.NewGame) return; try { ModLogger.Debug("Creating main window"); // Get a handle to the main game view UIView aView = UIView.GetAView(); // Create the gameobject and attach a mainwindow instance GameObject goMainWindow = new GameObject(WorkshopMonitorMainWindowGameObjectName); _mainWindow = goMainWindow.AddComponent<UIMainWindow>(); _mainWindow.transform.parent = aView.transform; ModLogger.Debug("Main window created"); } catch (Exception ex) { ModLogger.Error("An error occured while creating the main window"); ModLogger.Exception(ex); } }
public override void OnLevelLoaded(LoadMode mode) { EconomyManager em = Singleton<EconomyManager>.instance; DifficultyManager d = Singleton<DifficultyManager>.instance; if (mode == LoadMode.NewGame) { int moneyToAdd = (d.InitialMoney.Value - 70) * 100000; em.AddResource(EconomyManager.Resource.LoanAmount, moneyToAdd, ItemClass.Service.None, ItemClass.SubService.None, ItemClass.Level.None); } if (mode == LoadMode.NewGame || mode == LoadMode.LoadGame) { for (int i = 0; i < 3; i++) { EconomyManager.Bank bank = em.m_properties.m_banks[i]; EconomyManager.LoanInfo li = bank.m_loanOffers[0]; int newAmount = (int)Math.Round(li.m_amount * 0.01f * d.LoanMultiplier.Value); int newLength = (int)Math.Round(li.m_length * (1 + 0.01f * d.LoanMultiplier.Value) / 2f); // Halve the effect to prevent too long loan length. Helper.ValueChangedMessage(bank.m_bankName, "Loan amount", li.m_amount, newAmount); Helper.ValueChangedMessage(bank.m_bankName, "Loan length", li.m_length, newLength); li.m_amount = newAmount; li.m_length = newLength; bank.m_loanOffers[0] = li; em.m_properties.m_banks[i] = bank; } } Achievements.Update(); PrefabsManager.UpdatePrefabs(false); NetManager.UpdateSlopes(false); }
public override void OnLevelLoaded(LoadMode mode) { if (mode == LoadMode.LoadAsset || mode == LoadMode.NewAsset) { SelectAIPanel.Insert(); } }
public override void OnLevelLoaded (LoadMode mode) { // See https://gist.github.com/reima/9ba51c69f65ae2da7909 var ui = UIView.GetAView(); var button = (UIButton) ui.AddUIComponent (typeof(UIButton)); // Set the button's text and size. button.text = "Deduplicate Trees"; button.width = 200; button.height = 30; // Style the button to look like a menu button. button.normalBgSprite = "ButtonMenu"; button.disabledBgSprite = "ButtonMenuDisabled"; button.hoveredBgSprite = "ButtonMenuHovered"; button.focusedBgSprite = "ButtonMenuFocused"; button.pressedBgSprite = "ButtonMenuPressed"; button.textColor = new Color32(255, 255, 255, 255); button.disabledTextColor = new Color32(7, 7, 7, 255); button.hoveredTextColor = new Color32(7, 132, 255, 255); button.focusedTextColor = new Color32(255, 255, 255, 255); button.pressedTextColor = new Color32(30, 30, 44, 255); button.playAudioEvents = true; // Place the button. // FIXME: Might overlap some other mods' buttons. (Traffic++?) button.transformPosition = new Vector3(-1.65f, 0.97f); // Set the callback for clicks. button.eventClick += OnButtonClick; }
public static void CreateToolbars(LoadMode loadMode) { foreach (var plugin in plugins) { plugin.CreateToolbars(loadMode); } }
public override void OnLevelLoaded(LoadMode mode) { if (mode == LoadMode.NewGame || mode == LoadMode.LoadGame) { Redirector.PerformRedirections((ulong)PathfindingOptions); } }
public override void OnLevelLoaded(LoadMode mode) { if (mode != LoadMode.LoadGame && mode != LoadMode.NewGame && mode != LoadMode.NewMap && mode != LoadMode.LoadMap) return; lastLoadMode_ = mode; UIView view = UIView.GetAView(); UITabstrip tabStrip = null; whatsNewPanelGameObject = new GameObject("whatsNewPanel"); this.whatsNewPanel = whatsNewPanelGameObject.AddComponent<WhatsNewPanel>(); this.whatsNewPanel.transform.parent = view.transform; this.whatsNewPanel.Hide(); exportPanelGameObject = new GameObject("exportPanel"); this.exportPanel = exportPanelGameObject.AddComponent<ExportPanel>(); this.exportPanel.transform.parent = view.transform; this.exportPanel.whatsNewPanel = whatsNewPanel; this.exportPanel.Hide(); if (mode == LoadMode.NewGame || mode == LoadMode.LoadGame) { tabStrip = ToolsModifierControl.mainToolbar.component as UITabstrip; } else { tabStrip = UIView.Find<UITabstrip>("MainToolstrip"); } buttonObject = UITemplateManager.GetAsGameObject("MainToolbarButtonTemplate"); buttonObject2 = UITemplateManager.GetAsGameObject("ScrollablePanelTemplate"); menuButton = tabStrip.AddTab("cimtographerMod", buttonObject, buttonObject2, new Type[] { }) as UIButton; menuButton.eventClick += uiButton_eventClick; }
protected ModuleBase(bool iocContainerCanBeNull, LoadMode supportedModes = LoadMode.All, int priority = DefaultModulePriority) { _iocContainerCanBeNull = iocContainerCanBeNull; _priority = priority; _supportedModes = supportedModes; _locker = new object(); }
public override void OnLevelLoaded(LoadMode mode) { if (mode != LoadMode.LoadGame && mode != LoadMode.NewGame && mode != LoadMode.NewMap && mode != LoadMode.LoadMap) return; _mode = mode; buildingWindowGameObject = new GameObject("buildingWindowObject"); var view = UIView.GetAView(); this.buildingWindow = buildingWindowGameObject.AddComponent<MapperWindow7>(); this.buildingWindow.transform.parent = view.transform; this.buildingWindow.position = new Vector3(300, 122); this.buildingWindow.Hide(); UITabstrip strip = null; if (mode == LoadMode.NewGame || mode == LoadMode.LoadGame) { strip = ToolsModifierControl.mainToolbar.component as UITabstrip; } else { strip = UIView.Find<UITabstrip>("MainToolstrip"); } buttonObject = UITemplateManager.GetAsGameObject("MainToolbarButtonTemplate"); buttonObject2 = UITemplateManager.GetAsGameObject("ScrollablePanelTemplate"); menuButton = strip.AddTab("mapperMod", buttonObject, buttonObject2, new Type[] { }) as UIButton; menuButton.eventClick += uiButton_eventClick; }
protected MvvmApplication(LoadMode mode = LoadMode.Runtime) { ServiceProvider.DesignTimeManager = DesignTimeManagerImpl.Instance; Current = this; _mode = mode; _platform = PlatformInfo.Unknown; _context = new DataContext(); }
public const Int32 AW_BLEND = 0x00080000; // 使用淡入效果。只有当hWnd为顶层窗口的时候才可以使用此标志 #endregion************************************************* #region ***********************方 法*********************** /// <summary> /// 构造方法 /// </summary> /// <param name="loadMode">加载模式</param> /// <param name="message">消息正文</param> public static void Show(LoadMode loadMode, string message) { FormMode = loadMode; ShowMessage = message; FormMessageBox box = new FormMessageBox(); box.Show(); }
public override void OnLevelLoaded(LoadMode mode) { if (mode != LoadMode.LoadGame && mode != LoadMode.NewGame) return; UnLoading = false; CreateGraphics (); }
private void AddExtendedAttributeLoader(IExtendedAttributeLoader loader, LoadMode mode) { if (loader.SupportsMode(mode)) { m_extendedAttributeLoaders.Add(loader.AppliesTo, loader); loader.GameLoader = this; } }
private void AddXMLLoader(IXMLLoader loader, LoadMode mode) { InitXMLLoader(loader); if (loader.AppliesTo != null && loader.SupportsMode(mode)) { m_xmlLoaders.Add(loader.AppliesTo, loader); } }
private void AddExtendedAttributeLoaders(LoadMode mode) { foreach (Type t in AxeSoftware.Utility.Classes.GetImplementations(System.Reflection.Assembly.GetExecutingAssembly(), typeof(IExtendedAttributeLoader))) { AddExtendedAttributeLoader((IExtendedAttributeLoader)Activator.CreateInstance(t), mode); } }
public override void OnLevelLoaded(LoadMode mode) { base.OnLevelLoaded(mode); foreach (string s in debugLog) { Debug.Log(s); } }
public ModuleContext(PlatformInfo platform, LoadMode mode, IIocContainer iocContainer, IDataContext context, IList<Assembly> assemblies) { _platform = platform ?? PlatformInfo.Unknown; _mode = mode; _iocContainer = iocContainer; _context = context.ToNonReadOnly(); _assemblies = assemblies ?? Empty.Array<Assembly>(); }
public override void OnLevelLoaded(LoadMode mode) { if (mode == LoadMode.LoadGame || mode == LoadMode.NewGame) { SkylinesOverwatch.Settings.Instance.Enable.BuildingMonitor = V10Bulldoze.active = true; V10Bulldoze.ui = new UserInterface (); if (V10Bulldoze.ui.data.disableEffect) UserInterface.toggleEffects (); } }
public override void OnLevelLoaded(LoadMode mode) { base.OnLevelLoaded(mode); if (mode == LoadMode.LoadGame || mode == LoadMode.NewGame) { PropRemover.Initialize(); } }
public override void OnLevelLoaded(LoadMode mode) { base.OnLevelLoaded(mode); if (mode == LoadMode.LoadGame || mode == LoadMode.NewGame) { redirectState = RedirectionHelper.RedirectCalls( typeof(BulldozeTool).GetMethod("GetService", BindingFlags.Instance | BindingFlags.Public), typeof(MoledozeTool).GetMethod("GetService", BindingFlags.Instance | BindingFlags.Public)); } }
public GameLoader(WorldModel worldModel, LoadMode mode) { m_worldModel = worldModel; m_scriptFactory = new ScriptFactory(worldModel); m_scriptFactory.ErrorHandler += AddError; AddLoaders(mode); AddExtendedAttributeLoaders(mode); AddXMLLoaders(mode); }
public override void OnLevelLoaded(LoadMode mode) { base.OnLevelLoaded(mode); Loader.CurrentLoadMode = mode; if (MoreEffectiveTransfer.IsEnabled) { if (mode == LoadMode.LoadGame || mode == LoadMode.NewGame) { DebugLog.LogToFileOnly("OnLevelLoaded"); DataInit(); InitDetour(); HarmonyInitDetour(); SetupGui(); MoreEffectiveTransfer.LoadSetting(); MoreEffectiveTransfer.debugMode = false; if (mode == LoadMode.NewGame) { DebugLog.LogToFileOnly("New Game"); } } } }
public override void OnLevelLoaded(LoadMode mode) { Dbg.Log("OnLevelLoaded"); try { if (GrantMeMoney.Instance == null) { Dbg.Log("Creating Instance"); GrantMeMoney.Instance = new GameObject(GrantMeMoney.ModName).AddComponent <GrantMeMoney>(); Object.DontDestroyOnLoad(GrantMeMoney.Instance); GrantMeMoney.Instance.Start(); GrantMeMoney.Instance.enabled = true; } else { Dbg.Log("Starting Instance"); GrantMeMoney.Instance.Start(); GrantMeMoney.Instance.enabled = true; } if (ModUi.Instance == null) { try { Dbg.Log("Creating UI..."); ModUi.Instance = ToolsModifierControl.toolController.gameObject.AddComponent <ModUi>(); } catch (Exception e) { Dbg.Err("Could not create UI", e); } } } catch (Exception e) { Dbg.Err("Creating Instance FAILED", e); } }
public override void OnLevelLoaded(LoadMode mode) { base.OnLevelLoaded(mode); CSLMusicMod.Log("Got OnLevelLoaded: " + mode); if (mode == LoadMode.LoadGame || mode == LoadMode.NewGame || mode == LoadMode.NewGameFromScenario) { CSLMusicMod.Log("Level loaded. Loading mod components."); RemoveUnsupportedContent(); UserRadioContainer.CollectPostLoadingData(); ExtendVanillaContent(); // Build UI and other post loadtime if (UI == null && ModOptions.Instance.EnableCustomUI) { UI = new GameObject("CSLMusicMod_UI").AddComponent <MusicUI>(); } if (UIShortcutHandler == null && ModOptions.Instance.EnableShortcuts) { UIShortcutHandler = new GameObject("CSLMusicMod_UIShortcutHandler").AddComponent <ShortcutHandler>(); } if (DisabledContentContainer == null) { DisabledContentContainer = new GameObject("CSLMusicMod_DisabledContent").AddComponent <RadioContentWatcher>(); } try { DebugOutput(); } catch (Exception ex) { Debug.LogError("[CSLMusic] DebugOutput Error: " + ex); } } }
/// <summary> /// 加载场景(异步) /// </summary> /// <param name="info">资源信息标记</param> /// <param name="loadingAction">加载中事件</param> /// <param name="loadDoneAction">加载完成事件</param> /// <returns>加载协程迭代器</returns> public IEnumerator LoadSceneAsync(SceneInfo info, HTFAction <float> loadingAction, HTFAction loadDoneAction) { DateTime beginTime = DateTime.Now; if (_isLoading) { yield return(_loadWait); } _isLoading = true; yield return(LoadDependenciesAssetBundleAsync(info.AssetBundleName)); DateTime waitTime = DateTime.Now; if (LoadMode == ResourceLoadMode.Resource) { throw new HTFrameworkException(HTFrameworkModule.Resource, "加载场景失败:场景加载不允许使用Resource模式!"); } else { yield return(LoadAssetBundleAsync(info.AssetBundleName, loadingAction)); yield return(SceneManager.LoadSceneAsync(info.AssetPath, LoadSceneMode.Additive)); } DateTime endTime = DateTime.Now; Log.Info(string.Format("异步加载场景完成[{0}模式]:{1}\r\n等待耗时:{2}秒 加载耗时:{3}秒" , LoadMode.ToString() , info.AssetPath , (waitTime - beginTime).TotalSeconds , (endTime - waitTime).TotalSeconds)); loadDoneAction?.Invoke(); _isLoading = false; }
public override void OnLevelLoaded(LoadMode mode) { // Get the UIView object. This seems to be the top-level object for most // of the UI. var uiView = UIView.GetAView(); // Add a new button to the view. var button = (UIButton)uiView.AddUIComponent(typeof(UIButton)); // Set the text to show on the button. button.text = "Terrain contour!"; // Set the button dimensions. button.width = 150; button.height = 40; // Style the button to look like a menu button. button.normalBgSprite = "ButtonMenu"; button.disabledBgSprite = "ButtonMenuDisabled"; button.hoveredBgSprite = "ButtonMenuHovered"; button.focusedBgSprite = "ButtonMenuFocused"; button.pressedBgSprite = "ButtonMenuPressed"; button.textColor = new Color32(255, 255, 255, 255); button.disabledTextColor = new Color32(7, 7, 7, 255); button.hoveredTextColor = new Color32(7, 132, 255, 255); button.focusedTextColor = new Color32(255, 255, 255, 255); button.pressedTextColor = new Color32(30, 30, 44, 255); // Enable button sounds. button.playAudioEvents = true; // Place the button. button.transformPosition = new Vector3(-1.0f, 0.87f); // Respond to button click. button.eventClick += ButtonClick; }
/// <summary> /// Called when a game level is loaded. If applicable, activates the Real Time mod for the loaded level. /// </summary> /// <param name="mode">The <see cref="LoadMode"/> a game level is loaded in.</param> public override void OnLevelLoaded(LoadMode mode) { if (string.IsNullOrEmpty(modPath)) { MessageBox.Show("Sorry", NoWorkshopMessage); return; } switch (mode) { case LoadMode.LoadGame: case LoadMode.NewGame: case LoadMode.LoadScenario: case LoadMode.NewGameFromScenario: break; default: return; } Log.Info($"The 'Real Time' mod starts, game mode {mode}."); core?.Stop(); bool isNewGame = mode == LoadMode.NewGame || mode == LoadMode.NewGameFromScenario; core = RealTimeCore.Run(configProvider, modPath, localizationProvider, isNewGame); if (core == null) { Log.Warning("Showing a warning message to user because the mod isn't working"); MessageBox.Show( localizationProvider.Translate(TranslationKeys.Warning), localizationProvider.Translate(TranslationKeys.ModNotWorkingMessage)); } else { CheckCompatibility(); } }
private static void LoadImageAndReport(LoadMode mode, string filename) { switch (mode) { case LoadMode.System: using (var image = System.Drawing.Image.FromFile(filename)) { Console.WriteLine("{0} image size = {1}w by {2}h", System.IO.Path.GetFileName(filename), image.Width, image.Height); MemoryManagement.CheckMemory("With image loaded", true); } break; case LoadMode.Palaso: using (var image = SIL.Windows.Forms.ImageToolbox.PalasoImage.FromFile(filename)) { Console.WriteLine("{0} image size = {1}w by {2}h", System.IO.Path.GetFileName(filename), image.Image.Width, image.Image.Height); MemoryManagement.CheckMemory("With image loaded", true); } break; case LoadMode.ImageProcessor: using (var factory = new ImageProcessor.ImageFactory(true)) { factory.Load(filename); Console.WriteLine("{0} image size = {1}w by {2}h", System.IO.Path.GetFileName(filename), factory.Image.Width, factory.Image.Height); MemoryManagement.CheckMemory("With image loaded", true); } break; case LoadMode.ImageSharp: using (var image = SixLabors.ImageSharp.Image.Load(filename)) { Console.WriteLine("{0} image size = {1}w by {2}h", System.IO.Path.GetFileName(filename), image.Width, image.Height); MemoryManagement.CheckMemory("With image loaded", true); } break; } }
public override void OnLevelLoaded(LoadMode mode) { if (mode != LoadMode.LoadGame && mode != LoadMode.NewGame) { return; } _mode = mode; buildingWindowGameObject = new GameObject("buildingWindowObject"); var buildingInfo = UIView.Find <UIPanel>("(Library) ZonedBuildingWorldInfoPanel"); if (buildingInfo == null) { throw new ExtendedLoadingException("UIPanel not found (update broke the mod!): (Library) ZonedBuildingWorldInfoPanel\nAvailable panels are:\n" + string.Join(" \n", GetUIPanelNames())); //FindObjectsOfType<UIPanel>().Select(p => p.name).ToArray())); } this.buildingWindow = buildingWindowGameObject.AddComponent <BuildingInfoWindow5>(); this.buildingWindow.transform.parent = buildingInfo.transform; this.buildingWindow.size = new Vector3(buildingInfo.size.x, buildingInfo.size.y); this.buildingWindow.baseBuildingWindow = buildingInfo.gameObject.transform.GetComponentInChildren <ZonedBuildingWorldInfoPanel>(); this.buildingWindow.position = new Vector3(0, 12); buildingInfo.eventVisibilityChanged += buildingInfo_eventVisibilityChanged; var serviceBuildingInfo = GetPanel("(Library) CityServiceWorldInfoPanel");//UIView.Find<UIPanel>("(Library) CityServiceWorldInfoPanel"); if (serviceBuildingInfo == null) { throw new ExtendedLoadingException("UIPanel not found (update broke the mod!): (Library) CityServiceWorldInfoPanel\nAvailable panels are:\n" + string.Join(" \n", GetUIPanelNames())); } serviceWindow = buildingWindowGameObject.AddComponent <ServiceInfoWindow2>(); serviceWindow.servicePanel = serviceBuildingInfo.gameObject.transform.GetComponentInChildren <CityServiceWorldInfoPanel>(); serviceBuildingInfo.eventVisibilityChanged += serviceBuildingInfo_eventVisibilityChanged; }
public override void OnLevelLoaded(LoadMode mode) { // Get the UIView object. This seems to be the top-level object for most // of the UI. var uiView = UIView.GetAView(); // Add a new button to the view. button = (UIButton)uiView.AddUIComponent(typeof(UIButton)); // Set the text to show on the button. button.text = "Destroy everything!"; // Set the button dimensions. button.width = 175; button.height = 30; // Style the button to look like a menu button. button.normalBgSprite = "ButtonMenu"; button.disabledBgSprite = "ButtonMenuDisabled"; button.hoveredBgSprite = "ButtonMenuHovered"; button.focusedBgSprite = "ButtonMenuFocused"; button.pressedBgSprite = "ButtonMenuPressed"; button.textColor = new Color32(255, 255, 255, 255); button.disabledTextColor = new Color32(7, 7, 7, 255); button.hoveredTextColor = new Color32(7, 132, 255, 255); button.focusedTextColor = new Color32(255, 255, 255, 255); button.pressedTextColor = new Color32(30, 30, 44, 255); // Enable button sounds. button.playAudioEvents = true; // Place the button near the bulldoze icon button.transformPosition = new Vector3(1.3f, -0.85f); // Respond to button click. button.eventClick += ButtonClick; Debug.Log("DEYC: UI button created"); }
public void OnLevelLoaded(LoadMode mode) { _cachedMode = mode; while (LateBuildUpQueue.Count > 0) { try { LateBuildUpQueue.Dequeue().Invoke(); } catch (Exception e) { UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel").SetMessage("Enable asset in Content Manager!", e.Message, false); } } if (_updater == null) { _updater = new AssetsUpdater(); _updater.UpdateExistingAssets(mode); } AssetsUpdater.UpdateBuildingsMetroPaths(mode, false); if (mode == LoadMode.NewGame || mode == LoadMode.LoadGame || mode == LoadMode.NewGameFromScenario) { SimulationManager.instance.AddAction(DespawnVanillaMetro); var gameObject = new GameObject("MetroOverhaulUISetup"); gameObject.AddComponent <UpgradeSetup>(); gameObject.AddComponent <StyleSelectionUI>(); if (OptionsWrapper <Options> .Options.metroUi) { UIView.GetAView().AddUIComponent(typeof(MetroStationCustomizerUI)); } var transportInfo = PrefabCollection <TransportInfo> .FindLoaded("Metro"); transportInfo.m_netLayer = ItemClass.Layer.Default | ItemClass.Layer.MetroTunnels; transportInfo.m_stationLayer = ItemClass.Layer.Default | ItemClass.Layer.MetroTunnels; } }
/// <summary> /// Called when a game level is loaded. If applicable, activates the Snooper mod /// for the loaded level. /// </summary> /// /// <param name="mode">The <see cref="LoadMode"/> a game level is loaded in.</param> public override void OnLevelLoaded(LoadMode mode) { switch (mode) { case LoadMode.LoadGame: case LoadMode.NewGame: case LoadMode.LoadScenario: case LoadMode.NewGameFromScenario: break; default: return; } IPatch[] patches = { WorldInfoPanelPatches.UpdateBindings, HumanAIPatches.StartMoving1, HumanAIPatches.StartMoving2, CargoTruckAIPatches.SetTarget, }; patcher = new MethodPatcher(HarmonyId, patches); HashSet <IPatch> patchedMethods = patcher.Apply(); if (patchedMethods.Count != patches.Length) { Debug.LogError("The 'Snooper' mod failed to perform method redirections"); patcher.Revert(); return; } WorldInfoPanelPatches.CitizenInfoPanel = CustomCitizenInfoPanel.Enable(); WorldInfoPanelPatches.TouristInfoPanel = CustomTouristInfoPanel.Enable(); WorldInfoPanelPatches.CitizenVehicleInfoPanel = CustomCitizenVehicleInfoPanel.Enable(); WorldInfoPanelPatches.ServiceVehicleInfoPanel = CustomCityServiceVehicleInfoPanel.Enable(); }
private EventMetadataVm CreateViewModelContract( EventMetadataRecord eventMeta, int?day, LoadMode mode = LoadMode.Full) { if (eventMeta == null) { throw new ArgumentNullException("eventMeta"); } var result = ViewModelFactory.CreateViewModel(eventMeta, mode, _storageProvider); result.Host = EntityService .ViewModelFactory.CreateViewModel(eventMeta.EntityRecord, mode, _storageProvider); if (mode == LoadMode.Full) { result.Venues = GetEventVenues(eventMeta, day); } return(result); }
public override void OnLevelLoaded(LoadMode mode) { try { _loadMode = mode; if (_loadMode != LoadMode.LoadGame && _loadMode != LoadMode.LoadScenario && _loadMode != LoadMode.NewGame && _loadMode != LoadMode.NewGameFromScenario) { return; } UIView uiView = UnityEngine.Object.FindObjectOfType <UIView>(); if (uiView != null) { _purchasePanelGameObject = new GameObject("PurchaseItPurchasePanel"); _purchasePanelGameObject.transform.parent = uiView.transform; _purchasePanelGameObject.AddComponent <PurchasePanel>(); } } catch (Exception e) { Debug.Log("[Purchase It!] Loading:OnLevelLoaded -> Exception: " + e.Message); } }
public virtual void Init(string assetBundlePath, string assetPath, LoadMode loadMode, params object[] args) { this.AssetBundlePath = assetBundlePath ?? ""; this.AssetPath = assetPath ?? ""; this.loadMode = loadMode; Progress = 0f; _initTime = Time.realtimeSinceStartup; _uniqueKey = null; ResultObject = null; Error = ErrorType.None; IsCompleted = false; IsReadyDisposed = false; if (string.IsNullOrEmpty(this.AssetBundlePath) && string.IsNullOrEmpty(this.AssetPath)) { } else { _uniqueKey = GenerateKey(this.AssetBundlePath, this.AssetPath); } Debuger.Log(LOG_TAG, "_uniqueKey={0}", _uniqueKey); }
/// <summary> /// Executed whenever a level completes its loading process. /// This mod the activates and patches the game using Hramony library. /// </summary> /// <param name="mode">The loading mode.</param> public override void OnLevelLoaded(LoadMode mode) { /* * This function can still be called when loading up the asset editor, * so we have to check where we are right now. */ switch (mode) { case LoadMode.LoadGame: case LoadMode.NewGame: case LoadMode.LoadScenario: case LoadMode.NewGameFromScenario: break; default: return; } // we write settings first so that settings can be updated in case harmony fails UnifyHarmonyVersions(); PatchController.Activate(); }
public override void OnLevelLoaded(LoadMode mode) { base.OnLevelLoaded(mode); this.sunShaftsEffect = Camera.main.gameObject.AddComponent <SunShaftsEffect>(); LoadShaders(); this.sunShaftsEffect.simpleClearShader = this.simpleClearShaderMaterial.shader; this.sunShaftsEffect.sunShaftsShader = this.sunShaftShaderMaterial.shader; this.sunShaftsEffect.sunTransform = new GameObject().transform; this.sunShaftsEffect.Init(); var gameObject = GameObject.Find("ModControl"); if (gameObject == (UnityEngine.Object)null) { gameObject = new GameObject("ModControl"); gameObject.AddComponent <ModControl>(); } var modControl = gameObject.GetComponent <ModControl>(); modControl.SendMessage("addMod", (object)"SunShafts"); modControl.SendMessage("setAction", (object)new Action(this.OnModControlGUI)); modControl.SendMessage("setHeight", (object)120f); }
public override void OnLevelLoaded(LoadMode mode) { try { this._loadMode = mode; if ((mode == LoadMode.LoadGame) || (mode == LoadMode.NewGame)) { UIView view = UnityEngine.Object.FindObjectOfType <UIView>(); if (view != null) { this._gameObject = new GameObject("WaterPipeUpgraderGui"); this._gameObject.transform.parent = view.transform; this._gameObject.AddComponent <Gui>(); Util.DebugPrint(this.Name + " onLevelLoaded"); } } } catch (Exception ex) { UnityEngine.Debug.LogException(ex); } }
public override void OnLevelLoaded(LoadMode mode) { if (ExportUIObj == null) { if (mode == LoadMode.NewGame || mode == LoadMode.LoadGame) { ExportUIObj = new GameObject(); ExportUIObj.AddComponent <ExportUI>(); } } UIView view = UIView.GetAView(); ExpmHolder.view = view; var c = view.FindUIComponent("IncomePanel"); ExpmHolder.IncomePanel = c; var pos = c.absolutePosition; ExpmHolder.buttonX = (pos.x + c.width) * view.inputScale - 2; ExpmHolder.buttonY = (pos.y) * view.inputScale; }
public override void OnLevelLoaded(LoadMode mode) { // Check if in-game: if (mode != LoadMode.LoadGame && mode != LoadMode.NewGame) { DebugUtils.Log($"Mod not loaded: only available in-game, not in editors."); return; } // Initialize the mod: AmericanRoadsignsTool.Initialize(); // Load mod config: AmericanRoadsignsTool.LoadConfig(); // Set assets path: AmericanRoadsignsTool.SetModPath(); // Init. assets: AmericanRoadsignsTool.InitProps(); // Replace/hide props: AmericanRoadsignsTool.ReplacePropsOnLoad(); // Retexture/hide props: AmericanRoadsignsTool.ChangePropsOnLoad(); // base.OnLevelLoaded(mode); }
public override void OnLevelLoaded(LoadMode mode) { if (mode == LoadMode.LoadGame || mode == LoadMode.NewGame) { UIView view = UIView.GetAView(); UI = ToolsModifierControl.toolController.gameObject.AddComponent <MainPanel>(); ModSettings.LoadSettings(); m_renderingManager = RenderingManager.instance; m_renderingManager.enabled = true; if (m_renderingManager != null && !m_renderingManager.m_registered) { RenderManager.RegisterRenderableManager(m_renderingManager); m_renderingManager.m_registered = true; m_renderingManager.ForceUpdate(); } MarkARouteOptions.mInGame = true; MarkARouteOptions.update(); } }
/// <summary> /// Unloads the current module. /// </summary> public void Unload(IModuleContext context) { Should.NotBeNull(context, "context"); if (context.IocContainer == null) { return; } lock (_locker) { _context = context; _iocContainer = context.IocContainer; _mode = context.Mode; try { UnloadInternal(); } finally { _context = null; _iocContainer = null; } } }
public static IplImage ByteArrayToIplImage(byte[] imageBuffer, LoadMode loadMode) { // OpenCvSharp.CPlusPlus.Mat m = Cv.EncodeImage(".jpg", img); IplImage res = IplImage.FromImageData((byte[])imageBuffer, loadMode); if (res == null) { Bitmap img = null; using (var ms = new System.IO.MemoryStream(imageBuffer)) { img = Image.FromStream(ms) as Bitmap; } Stream str = VaryQualityLevel(img); if (str != null) { imageBuffer = ReadStreamToEnd(str); str.Dispose(); str = null; } res = IplImage.FromImageData((byte[])imageBuffer, loadMode); } return(res); }
public override void OnLevelLoaded(LoadMode mode) { base.OnLevelLoaded(mode); Loader.CurrentLoadMode = mode; if (MoreOutsideInteraction.IsEnabled) { if (mode == LoadMode.LoadGame || mode == LoadMode.NewGame) { DebugLog.LogToFileOnly("OnLevelLoaded"); InitDetour(); for (int i = 0; i < 65536; i++) { CustomPlayerBuildingAI.canReturn[i] = false; } HarmonyInitDetour(); MoreOutsideInteraction.LoadSetting(); if (mode == LoadMode.NewGame) { DebugLog.LogToFileOnly("New Game"); } } } }
public override void OnLevelLoaded(LoadMode mode) { //DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "OnLevelLoaded()"); TurnData.loadTurnData(); ClientData.loadData(); //DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, ClientData.hostIP + "turnDuration: " + HostConfigData.turnDuration + " turn: " +HostConfigData.turn + " player name: " + HostConfigData.playerTurnName ); if (ClientData.hostIP == "0.0.0.0") { PMThreading.PMActive = false; return; } HostConfigData.fetchRemoteData(ClientData.name, ClientData.code, ClientData.hostIP); if (HostConfigData.playerTurnName == ClientData.name || HostConfigData.turn == 0) { //DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "PMActive == true"); PMThreading.PMActive = true; } else { //DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "PMActive == false"); PMThreading.PMActive = false; } }
protected override void OnLoaded(LoadMode loadMode) { base.OnLoaded(loadMode); OnLoadedCalled = true; OnLoadedTx = ClientTransaction.Current; OnLoadedLoadMode = loadMode; ++OnLoadedCallCount; if (ProtectedLoaded != null) { ProtectedLoaded(this, EventArgs.Empty); } if (StaticLoadHandler != null) { StaticLoadHandler(this, EventArgs.Empty); } if (_loadEventReceiver != null) { _loadEventReceiver.OnLoaded(this); } }
/// <summary> /// Called when a game level is loaded. If applicable, activates the Real Time mod /// for the loaded level. /// </summary> /// /// <param name="mode">The <see cref="LoadMode"/> a game level is loaded in.</param> public override void OnLevelLoaded(LoadMode mode) { switch (mode) { case LoadMode.LoadGame: case LoadMode.NewGame: case LoadMode.LoadScenario: case LoadMode.NewGameFromScenario: break; default: return; } core = RealTimeCore.Run(config, modPath, localizationProvider); if (core == null) { Log.Warning("Showing a warning message to user because the mod isn't working"); MessageBox.Show( localizationProvider.Translate(TranslationKeys.Warning), localizationProvider.Translate(TranslationKeys.ModNotWorkingMessage)); } }
public override void OnLevelLoaded(LoadMode mode) { base.OnLevelLoaded(mode); Debug.Log("Begin NetworkSkinsMod.OnLevelLoaded"); SegmentDataManager.Instance.OnLevelLoaded(); // Don't load if it's not a game if (!CheckLoadMode(mode)) { return; } // GUI if (panel == null) { panel = UIView.GetAView().AddUIComponent(typeof(UINetworkSkinsPanel)) as UINetworkSkinsPanel; } panel.isVisible = true; Debug.Log("End NetworkSkinsMod.OnLevelLoaded"); }
public static WordEdit OpenEdit(FileInfo wordFile, LoadMode loadMode) { Contracts.Require(wordFile.Exists); Contracts.Require(wordFile.Extension == ".docx", "only .docx files supported"); Word.Application app = OpenWord(); Word.Document document = app.Documents.Open(wordFile.FullName, ReadOnly: false, Visible: true); return(new WordEdit { Application = app, Document = document, File = wordFile, LoadMode = loadMode }); Word.Application OpenWord() { return(loadMode == LoadMode.FullDispose ? new Word.Application() : Marshal.GetActiveObject("Word.Application") as Word.Application); } }
public override byte[] LoadFile(string filePath, LoadMode mode) { byte[] data = null; switch (mode) { case LoadMode.Internal: TextAsset ta = Resources.Load <TextAsset>(filePath); if (ta != null) { data = ta.bytes; } break; case LoadMode.Editor: case LoadMode.Persistent: if (File.Exists(filePath)) { using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { data = new byte[fs.Length]; fs.Read(data, 0, data.Length); } } break; case LoadMode.ReadOnly: using (WWW www = new WWW(StringUtil.GetFileProtocolPath(filePath))) { while (!www.isDone) { } data = www.bytes; } break; } return(data); }
public override void OnLevelLoaded(LoadMode mode) { if (!HarmonyHelper.IsHarmonyInstalled) { return; } _loadMode = mode; if (mode != LoadMode.LoadGame && mode != LoadMode.NewGame && _loadMode != LoadMode.NewGameFromScenario) { return; } var objectOfType = Object.FindObjectOfType <UIView>(); if (objectOfType != null) { _gameObject = new GameObject("PanelExtenderCityService") { transform = { parent = objectOfType.transform } }; _gameObject.AddComponent <PanelExtenderCityService>(); } VehiclePrefabs.Init(); PanelExtenderCityServicePatch.Apply(); //needed for reverse redirect XYZBuildingAIPatch.Apply(); CargoTruckAIChangeVehicleTypePatch.Apply(); GetVehicleInfoPatch.Apply(); GetSelectedVehiclePatch.Apply(); CreateVehiclePatch.Apply(); SimulationManager.instance.AddAction(SerializableDataExtension.ValidateBuildingData); }