public UploadOptions(ModObject mod) { InitializeComponent(); if (!DesignMode) { mod.Refresh(); comboBox1.SelectedIndex = 0; comboBox2.SelectedIndex = 0; comboBox3.SelectedIndex = 0; this.mod = mod; this.store = ModStore.LoadForMod(mod); LoadGUITags((store.Tags != null && store.Tags.Count() > 0) ? store.Tags : null); textBox1.Text = store.Changelog; comboBox3.SelectedIndex = store.Visibility; checkBox1.Checked = store.UploadUnCookedContent; checkBox2.Checked = store.UploadScripts; checkBox13.Checked = store.ForceNoTags; checkBox13_CheckedChanged(null, null); var wsid = mod.GetUploadedId(); if (wsid > 0) { label6.Text = "WorkshopId: " + wsid; mButton4.Visible = false; } else { mButton4.Visible = true; } } }
public static Conclusion GetHmods(Tasker tasker, Object modObject) { if (!(modObject is ModObject)) { return(Conclusion.Error); } ModObject unboxedObject = (ModObject)modObject; unboxedObject.LoadedHmods = new List <Hmod>(); if (unboxedObject.HmodsToLoad == null) { return(Conclusion.Error); } tasker.SetStatus(Properties.Resources.LoadingHmods); int progress = 0; foreach (string mod in unboxedObject.HmodsToLoad) { unboxedObject.LoadedHmods.Add(new Hmod(mod, unboxedObject.InstalledHmods)); progress++; tasker.SetProgress(progress, unboxedObject.HmodsToLoad.Count); } tasker.SetProgress(1, 1); return(Conclusion.Success); }
public static void DetachWatcher(ModObject o) { if (WatcherProcesses.ContainsKey(o.GetDirectoryName())) { WatcherProcesses[o.GetDirectoryName()].Dispose(); WatcherProcesses.Remove(o.GetDirectoryName()); } }
public static void AttachWatcher(ModObject o) { if (WatcherProcesses.ContainsKey(o.GetDirectoryName())) { return; } WatcherProcesses.Add(o.GetDirectoryName(), new ScriptWatcher(o)); }
public long GetIdForMod(ModObject mod) { var dirname = mod.GetDirectoryName(); if (SteamWorkshopData.ContainsKey(dirname)) { return(SteamWorkshopData[dirname]); } return(0); }
// Update is called once per frame public async Task Reload(ModObject v) { await ModSystemTools.LoadPartsAsync(); target = v; Titlebar.text = $"Modify {TranslationSystem.GetString("CAR_"+target.Name)}"; PrepareCatButtons(); PrepareTypeButtons(); StatView.ShowValues(target); }
public void LoadGUITags(string[] tags) { List <string> tmp = new List <string>(); if (tags == null) { var tagsS = ModObject.CombineTags(mod.GetModClasses()); foreach (var tag in tagsS) { tmp.Add(ModClass.ClassToNameMapping[tag]); } foreach (var tag in mod.GetIniTags()) { if (!tmp.Contains(tag)) { tmp.Add(tag); } } tags = tmp.ToArray(); } foreach (var c in borderPanel1.Controls) { if (c is CheckBox) { var cb = (CheckBox)c; if (tags.Contains(cb.Text)) { cb.Checked = true; } } else if (c is ComboBox) { var cb = (ComboBox)c; int i = 0; foreach (var item in cb.Items) { if (i == 0) { i++; continue; } if (tags.Contains((string)item)) { cb.SelectedIndex = i; break; } i++; } } } }
// Update is called once per frame public void ShowValues(ModObject target) { VehicleInfo info = VTypes.FirstOrDefault(x => x.name == target.Name + "I"); Handling.fillAmount = info.Handling / 100f; Health.fillAmount = info.HP / 180f; Power.fillAmount = info.Power / 400f; Power2.fillAmount = target.GetComponentInChildren <EngineManager>().GetPower() / 400f; Handling2.fillAmount = target.GetComponentInChildren <HandlingManager>().GetHandling() / 100f; Health2.fillAmount = target.GetComponentInChildren <HealthManager>().GetHealth() / 180f; }
public ModProperties(ModObject mod) { this.HandleCreated += ModProperties_HandleCreated; InitializeComponent(); HasUnsavedChanges = false; this.Mod = mod; this.configList1.OnUpdate += ConfigList1_OnUpdate; this.arList1.OnUpdate += ConfigList1_OnUpdate; Reload(); }
public void LoadMod(ModObject mod) { HasContentError = false; AssetNameLabel.Text = "(none selected)"; AssetDescriptionLabel.Text = ""; ContentTreeView.Nodes.Clear(); IterateContent(ContentTreeView.Nodes, mod, mod.GetContentDir(), ".upk", true); IterateContent(ContentTreeView.Nodes, mod, mod.GetMapsDir(), ".umap", true); IterateContent(ContentTreeView.Nodes, mod, mod.GetLocsDir(), ".int", true); ContentTreeView.ExpandAll(); }
public ConfigItem(ModObject.ModConfigItem item, ModObject ob) { InitializeComponent(); Conf = item; Obj = ob; label4.Text = Conf.PropertyName; label3.Text = Conf.Description.Replace("[br]", Environment.NewLine); label5.Text = Conf.Name; RepopulateOptionsDict(true); }
public void UploadModAsync(ModObject mod, string changelog, string[] tags, bool keepCooked, bool keepScripts, int visibility, string description) { Task.Factory.StartNew(() => { MainWindow.Instance.Invoke(new MethodInvoker(() => { ModProperties.TemporaryHideAllPropertiesWindows(); })); UploadMod(mod, changelog, tags, keepCooked, keepScripts, visibility, description); MainWindow.Instance.Invoke(new MethodInvoker(() => { ModProperties.RestoreTemporaryHiddenPropertiesWindows(); })); }); }
public void SaveForMod(ModObject mod) { var path = Path.Combine(mod.RootPath, "uploader.xml"); XmlSerializer serializer = new XmlSerializer(typeof(ModStore)); Stream fs = new FileStream(path, FileMode.Create); XmlWriter writer = new XmlTextWriter(fs, Encoding.Unicode); // Serialize using the XmlTextWriter. serializer.Serialize(writer, this); writer.Close(); }
public void SetIdForMod(ModObject mod, long value) { var dirname = mod.GetDirectoryName(); if (SteamWorkshopData.ContainsKey(dirname)) { SteamWorkshopData[dirname] = value; } else { SteamWorkshopData.Add(dirname, value); } Save(); }
public void Append(ModObject.ModConfigItem conf, ModObject o) { this.flowLayoutPanel1.SuspendLayout(); var e = new ConfigItem(conf, o); e.Padding = new Padding(0); e.Width = flowLayoutPanel1.ClientSize.Width - BarOffset; this.flowLayoutPanel1.Controls.Add(e); this.flowLayoutPanel1.ResumeLayout(); UpdateWidths(); }
public static ModProperties GetPropertiesWindowForMod(ModObject mod) { foreach (Form frm in Application.OpenForms) { if (frm is ModProperties) { var form = (ModProperties)frm; if (form.Mod.Equals(mod)) { return(form); } } } return(null); }
public ExecutableArgumentsPair GetCompileScript(ModObject mod, bool watcher = false) { return(new ExecutableArgumentsPair( !watcher ? "Compiling scripts..." : "Changes in filesystem detected... Recompiling scripts...", EditorExecutablePath, new string[] { "make", "-FULL", "-SHORTPATHS", "-NOPAUSEONSUCCESS", "-MODSONLY=" + mod.GetDirectoryName() }, Path.GetDirectoryName(EditorExecutablePath) )); }
public ExecutableArgumentsPair GetCookMod(ModObject mod) { return(new ExecutableArgumentsPair( "Cooking mod...", EditorExecutablePath, new string[] { "CookPackages", "-PLATFORM=PC", "-NOPAUSEONSUCCESS", "-FULL", "-FASTCOOK", "-MULTILANGUAGECOOK=" + (Properties.Settings.Default.MultilangCook ? "INT+CHN+DEU+ESN+FRA+ITA+JPN+KOR+PTB" : "INT"), "-MODSONLY=" + mod.GetDirectoryName() }, Path.GetDirectoryName(EditorExecutablePath) )); }
public void Fill(ModObject o) { ModObj = o; this.flowLayoutPanel1.SuspendLayout(); this.flowLayoutPanel1.Controls.Clear(); foreach (var item in o.Config) { var e = new ConfigItem(item, o); e.Padding = new Padding(0); e.Width = flowLayoutPanel1.ClientSize.Width - BarOffset; this.flowLayoutPanel1.Controls.Add(e); } this.flowLayoutPanel1.ResumeLayout(); UpdateWidths(); }
public async Task SpawnVehicle(int index) { if (preview != null) { Destroy(preview); } VCount.text = $"{index+1}/{Vehicles.Count}"; VehicleInfo info = VTypes.FirstOrDefault(x => x.name == Vehicles[index].Type + "I"); Handling.fillAmount = info.Handling / 100f; Health.fillAmount = info.HP / 180f; Power.fillAmount = info.Power / 400f; Name.text = TranslationSystem.GetString("CAR_" + info.name.Substring(0, info.name.Length - 1)); var v = Vehicles[index]; GameObject gm = new GameObject(); gm.transform.position = new Vector3(0, 1, 0); preview = gm; var modobj = gm.AddComponent <ModObject>(); await modobj.Create(v.Type); foreach (var item in v.InstalledParts) { modobj.AttachPart(item); } InitializedObject = modobj; //await Task.Delay(100); Power2.fillAmount = modobj.GetComponentInChildren <EngineManager>().GetPower() / 400f; Handling2.fillAmount = modobj.GetComponentInChildren <HandlingManager>().GetHandling() / 100f; Health2.fillAmount = modobj.GetComponentInChildren <HealthManager>().GetHealth() / 180f; foreach (var item in CallList) { try { item.Changed(index); } catch { } } }
public static ModStore LoadForMod(ModObject mod) { var path = Path.Combine(mod.RootPath, "uploader.xml"); if (File.Exists(path)) { try { var serializer = new XmlSerializer(typeof(ModStore)); using (Stream reader = new FileStream(path, FileMode.Open)) { return((ModStore)serializer.Deserialize(reader)); } } catch (Exception e) { Debug.WriteLine(e.Message + "\n" + e.ToString()); } } return(new ModStore()); }
public ModTile(ModObject mod) { InitializeComponent(); contextMenuStrip1.Renderer = new ToolStripProfessionalRenderer(new MenuColorTable()); contextMenuStrip1.BackColor = ThemeConstants.BackgroundColor; contextMenuStrip1.ForeColor = ThemeConstants.ForegroundColor; OriginalColor = this.BackColor; this.Mod = mod; this.panel1.BackgroundImage = mod.GetIcon(); this.label1.Text = mod.Name + "\n(" + mod.GetDirectoryName() + ")"; this.panel2.Visible = mod.IsReleased; checkBox1.CheckedChanged += CheckBox1_CheckedChanged; CheckBox1_CheckedChanged(null, null); this.MouseEnter += ModTile_MouseEnter; this.MouseLeave += ModTile_MouseLeave; this.panel1.MouseEnter += ModTile_MouseEnter; this.panel1.MouseLeave += ModTile_MouseLeave; this.label1.MouseEnter += ModTile_MouseEnter; this.label1.MouseLeave += ModTile_MouseLeave; checkBox1.Cursor = Cursors.Arrow; this.Click += ModTile_Click; this.panel1.Click += ModTile_Click; this.label1.Click += ModTile_Click; scriptWatcherToolStripMenuItem2.Checked = ScriptWatcherManager.IsWatcherAttached(Mod); RevalidateBG(); }
public ScriptWatcher(ModObject mod) { this.Mod = mod; var path = mod.RootPath; // Create a new FileSystemWatcher and set its properties. watcher = new FileSystemWatcher(); watcher.Path = Path.Combine(path, "Classes"); /* Watch for changes in LastAccess and LastWrite times, and * the renaming of files or directories. */ watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName; // Only watch script files. watcher.Filter = "*.uc"; // Add event handlers. watcher.Changed += new FileSystemEventHandler(OnChanged); watcher.Renamed += new RenamedEventHandler(OnRenamed); watcher.EnableRaisingEvents = true; }
public void Reload() { _saveFeatureHold = true; Mod.Refresh(); contentBrowser1.LoadMod(Mod); levelType.Items.Clear(); if (Mod.HasAnyMaps()) { levelType.Visible = true; label1.Visible = true; foreach (var a in ModObject.IniTagToSteamMapping) { levelType.Items.Add(a.Value); if (a.Key.Equals(Mod.MapType, StringComparison.InvariantCultureIgnoreCase)) { levelType.SelectedItem = a.Value; } } } else { levelType.Visible = false; label1.Visible = false; } var imageList = new ImageList(); imageList.ImageSize = new Size(36, 36); foreach (var img in Engine.ModClass.ClassToIconMapping) { imageList.Images.Add(img.Key.ToString(), img.Value); } this.Text = $"{Mod.Name.ToUpper()} (V. {Mod.Version})"; this.ModDescriptionEdit.Text = Mod.GetDescription(); this.modFolderName.Text = Mod.GetDirectoryName(); this.modName.Text = Mod.Name; this.cbOnlineParty.Checked = Mod.IsOnlineParty; this.iconView.BackgroundImage = Mod.GetIcon(); this.chapterInfoInput.Text = Mod.ChapterInfoName; this.cbCoOp.Checked = Mod.Coop.ToLower() == "cooponly"; this.cbOnlineParty.Checked = Mod.IsOnlineParty; this.label5.Text = Mod.Version; this.lblAuthor.Text = Mod.Author; var tags = ModObject.CombineTags(Mod.GetModClasses()); this.tagsList.Clear(); this.tagsList.LargeImageList = imageList; this.ModClass.Text = Mod.ModClass; foreach (var tag in tags) { if (Engine.ModClass.VisibleTypes.Contains(tag)) { this.tagsList.Items.Add("Contains " + Engine.ModClass.ClassToNameMapping[tag], tag.ToString()); } } if (Mod.HasAnyMaps()) { this.tagsList.Items.Add("Contains map", "Map"); } if (Mod.AssetReplacements.Count > 0) { this.tagsList.Items.Add("Asset Replace", "AssetReplace"); } if (Mod.AutoGiveItems) { this.tagsList.Items.Add("Items are available immediately", "AutoGiveItems"); } mButton1.Enabled = Mod.IsReleased; arList1.Fill(Mod.AssetReplacements); this.configList1.Fill(Mod); Debug.WriteLine("ConfigCount: " + Mod.Config.Count); var cooked = ReloadFlags(); if (Mod.IsReadOnly) { mButton4.Enabled = false; mButton5.Enabled = false; mButton6.Enabled = false; mButton7.Enabled = false; mButton8.Enabled = false; mButton10.Enabled = false; label5.Enabled = false; arList1.Enabled = false; chapterInfoInput.Enabled = false; cbOnlineParty.Enabled = false; cbCoOp.Enabled = false; levelType.Enabled = false; iconView.Enabled = false; modName.Enabled = false; modFolderName.Enabled = false; ModDescriptionEdit.ReadOnly = true; } comboBox1.Items.Clear(); panel2.Enabled = false; if (cooked) { //Mod.TestMod(MainWindow.Instance.Runner, "mafia_town"); comboBox1.Items.Add(new MapItem("hub_spaceship", "Spaceship")); comboBox1.Items.Add(new MapItem("mafia_town", "Mafia Town")); comboBox1.Items.Add(new MapItem("hatintimeentry", "HatInTimeEntry")); comboBox1.Items.Add(new MapItem("??menu", "Main Menu")); if (Mod.HasAnyCookedMaps()) { foreach (var a in Mod.GetCookedMaps()) { comboBox1.Items.Add(new MapItem(a)); } } comboBox1.SelectedIndex = comboBox1.Items.Count - 1; panel2.Enabled = true; } Store = ModStore.LoadForMod(Mod); checkBox1.Checked = Store.UseSeparateDescriptionForSteam; SteamDescription.Enabled = Store.UseSeparateDescriptionForSteam; SteamDescription.Text = Store.GetDescription(); _saveFeatureHold = false; HasUnsavedChanges = false; }
public static bool IsWatcherAttached(ModObject o) { return(WatcherProcesses.ContainsKey(o.GetDirectoryName())); }
public void UploadMod(ModObject mod, string changelog, string[] tags, bool keepUnCooked, bool keepScripts, int visibility, string description) { if (IsUploaderRunning) { MainWindow.Instance.Invoke(new MethodInvoker(() => { GUI.MessageBox.Show(MainWindow.Instance, "Only one uploader instance can run at once!"); })); return; } success = true; IsUploaderRunning = true; try { ERemoteStoragePublishedFileVisibility fileVisibility = (ERemoteStoragePublishedFileVisibility)Enum.ToObject(typeof(ERemoteStoragePublishedFileVisibility), visibility);; mod.Refresh(); SetStatus("Preparing the uploader..."); var tmpDir = Path.Combine(Program.GetAppRoot(), "uploader_tmp"); if (Directory.Exists(tmpDir)) { Directory.Delete(tmpDir, true); } Directory.CreateDirectory(tmpDir); Utils.DirectoryCopy(mod.RootPath, tmpDir, true); if (!keepScripts) { if (Directory.Exists(Path.Combine(tmpDir, "CompiledScripts"))) { Directory.Delete(Path.Combine(tmpDir, "CompiledScripts"), true); } if (Directory.Exists(Path.Combine(tmpDir, "Classes"))) { Directory.Delete(Path.Combine(tmpDir, "Classes"), true); } } if (!keepUnCooked) { if (Directory.Exists(Path.Combine(tmpDir, "Maps"))) { Directory.Delete(Path.Combine(tmpDir, "Maps"), true); } if (Directory.Exists(Path.Combine(tmpDir, "Content"))) { Directory.Delete(Path.Combine(tmpDir, "Content"), true); } } //var description = mod.GetDescription(); var modid = mod.GetUploadedId(); SetStatus("Creating callback..."); m_itemCreated = CallResult <CreateItemResult_t> .Create(OnItemCreated); var appId = new AppId_t(uint.Parse(GameFinder.AppID)); if (modid == 0) { SteamAPICall_t call = SteamUGC.CreateItem(appId, EWorkshopFileType.k_EWorkshopFileTypeCommunity); m_itemCreated.Set(call); } else { publishID = modid; } while (publishID == 0) { SteamAPI.RunCallbacks(); Thread.Sleep(1000); } Thread.Sleep(1000); if (modid == 0) { SetStatus("Uploading an new mod " + mod.Name + " with WorkshopID: " + publishID); mod.SetUploadedId(publishID); } else { SetStatus("Updating the mod " + mod.Name + " with WorkshopID: " + publishID); } var publishFileID_t = new PublishedFileId_t(publishID); ugcUpdateHandle = SteamUGC.StartItemUpdate(appId, publishFileID_t); SteamUGC.SetItemTitle(ugcUpdateHandle, mod.Name); SteamUGC.SetItemDescription(ugcUpdateHandle, description); SteamUGC.SetItemVisibility(ugcUpdateHandle, fileVisibility); if (tags != null) { SteamUGC.SetItemTags(ugcUpdateHandle, tags); } SteamUGC.SetItemPreview(ugcUpdateHandle, Path.Combine(tmpDir, mod.Icon)); SteamUGC.SetItemContent(ugcUpdateHandle, tmpDir); SteamAPICall_t t = SteamUGC.SubmitItemUpdate(ugcUpdateHandle, changelog); m_itemSubmitted = CallResult <SubmitItemUpdateResult_t> .Create(OnItemSubmitted); m_itemSubmitted.Set(t); while (true) { Thread.Sleep(1000); if (ugcUpdateHandle == UGCUpdateHandle_t.Invalid) { break; } SteamAPI.RunCallbacks(); ulong bytesDone, bytesTotal; EItemUpdateStatus status = SteamUGC.GetItemUpdateProgress(ugcUpdateHandle, out bytesDone, out bytesTotal); if (status == EItemUpdateStatus.k_EItemUpdateStatusInvalid && !success) { break; } SetStatus(string.Format("[{3}%] Status: {0}\n{1}/{2}", TranslateStatus(status), BytesToString(bytesDone), BytesToString(bytesTotal), bytesTotal > 0 ? Math.Floor(((double)bytesDone / (double)bytesTotal) * (double)100) : 100)); } DialogResult res = DialogResult.No; if (success) { MainWindow.Instance.Invoke(new MethodInvoker(() => { res = GUI.MessageBox.Show(MainWindow.Instance, "Done, mod url:" + "\nhttps://steamcommunity.com/sharedfiles/filedetails/?id=" + publishID + "\n\nOpen it in the browser?", "Uploader", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (res == DialogResult.Yes) { Process.Start("steam://openurl/https://steamcommunity.com/sharedfiles/filedetails/?id=" + publishID); } })); SetStatus("Item uploaded successfully!"); Thread.Sleep(1000); } SetStatus("Cleanup"); if (Directory.Exists(tmpDir)) { Directory.Delete(tmpDir, true); } SetStatus(null); IsUploaderRunning = false; } catch (Exception e) { MainWindow.Instance.Invoke(new MethodInvoker(() => { GUI.MessageBox.Show(MainWindow.Instance, e.Message + "\n" + e.ToString()); })); IsUploaderRunning = false; SetStatus(null); } }
private void IterateContent(TreeNodeCollection root, ModObject mod, string currPath, string acceptExt, bool isBase = false) { if (!Directory.Exists(currPath)) { return; } if (isBase) { var node = root.Add("folder", Path.GetFileName(currPath), "folder", "folder"); IterateContent(node.Nodes, mod, currPath, acceptExt); return; } foreach (string path in Directory.GetFiles(currPath, "*.*")) { Debug.WriteLine(GameFinder.GetCookedPcDir()); var exts = acceptExt.Split('|'); var extension = Path.GetExtension(path); var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(path); if (!exts.Contains(acceptExt)) { var treeNode = root.Add("", Path.GetFileName(path), "error", "error"); var text = "This asset does not belong here."; foreach (var a in Adict) { if (exts.Contains(a.Key)) { text += Environment.NewLine + a.Value; } } foreach (var b in BDict) { if (extension == b.Key) { text += Environment.NewLine + b.Value; } } treeNode.Tag = new ContentTreeViewInfo(Path.GetFileName(path), text); HasContentError = true; } else if (fileNameWithoutExtension.ToLower() == mod.GetDirectoryName().ToLower() && !exts.Contains(".int") && !exts.Contains(".umap")) { var treeNode = root.Add("", Path.GetFileName(path), "error", "error"); treeNode.Tag = new ContentTreeViewInfo(Path.GetFileName(path), "Packages can't have the same name as your mod folder.\nAdd a _Content suffix or something. Example:\n" + fileNameWithoutExtension + "_Content" + extension); HasContentError = true; } else if (Utils.FileExists(GameFinder.GetCookedPcDir(), Path.GetFileName(path))) { var treeNode = root.Add("", Path.GetFileName(path), "error", "error"); treeNode.Tag = new ContentTreeViewInfo(Path.GetFileName(path), "There's an asset with an identical name in CookedPC.\nPlease give your asset another name.\n(btw don't put your own stuff in CookedPC. Keep it to the mods folder.)"); HasContentError = true; } else { var ext = exts.Contains(".int") ? "localization" : "package"; var treeNode = root.Add("", Path.GetFileName(path), ext, ext); treeNode.Tag = new ContentTreeViewInfo(Path.GetFileName(path), ""); } } foreach (var file in Directory.GetDirectories(currPath)) { var node = root.Add("", Path.GetFileName(file), "folder", "folder"); IterateContent(node.Nodes, mod, file, acceptExt); } }